Finished documenting the methods and clean up.

Still needs to be re-factored to speed it up.