fix README and add a minor refactoring