cleaned up code and javadoc