Come more code cleanup and added javadoc