Added javadocs, cleaned code.