Added javadocs
Fixed minor bugs