Added license and README.md
javadoc and state related fixing and code refactoring