-added javadoc comments and fixed some bugs