updated README and a bit of code refactoring