Fix #61

Also made some code styling improvements
Merge pull request #62 from sourceLair/issue-61

Fix #61