Updated Javadoc and cleaned code