Fix bugs and javadocs