Added javadoc comments, cleaned up lots of stuff