Cleaned up some of the code.
Documentation yay!