Some refactoring, debugging and added example to README