code cleanup, javadoc added