Reordered some methods and added basic javadocs.