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

Adding code comments and a bit of refactoring