Added a lot of javadoc and did some cleaning