javadoc and state related fixing and code refactoring