Added comments, javadoc, slight restructure