Merged PR #7

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