Adding code comments
Merge pull request #12 from rhyolight/comments

Adding code comments and a bit of refactoring
Merge remote-tracking branch 'upstream/master' into add-test-coverage
Extracting code from index.js