Updated readme and some minor refactoring