Refactored code.
Updated readme.