Big refactoring
Merge pull request #5 from robparrott/master

Big refactoring!