Added Javadocs to everything, and did some small refactors.