Update README, and do minor code refactoring