some code cleanup, commenting and a few javadoc added