Code cleanup + javadoc