Code cleanup & javadoc