Add more comments and javadoc