Refactor + javadoc support.
Added javadoc