Added additional comments, fixed readme examples, simple code refactoring