Added more Javadoc and code cleanup