Code refactor and update to README.