Added javadoc for all public methods and constructors. Refactored when necessary.

Sorry about the huge commit, it's getting late and I was just double checking everything here to make sure that it all works fine.