pep8
cleaned up code and added more documentation. Also PEP8.