Oil pulling mechanism is still fairly unknown, but it seems that by placing oil in your mouth will trigger a response from liver and gallbladder to produce and purge bile (perhaps the the reason why you saw gallstones) - the same occurs when you eat any fat. Further more, as the liver is activated it may rattle up some toxins into the blood which can be released through saliva. Also any oil soluble substances in the mouth get dissolved in the oil and pulled out, perhaps improving the dental environment.
The thinner the oil mixture gets, the more saliva is present, which means more toxins out. However if you pull for too long the toxins may be absorbed back (places like tongue and under the tongue are known to be areas of quick absorption).