Adding javadoc
Cleaning up code