Merged PR #7

Merged pull request #7 after fixing a few possible issues.