Olmstead and reimplemented with the help of his source code which he was kind enough to release into the public domain. [originally from svn r6222]