Merge pull request #2 from michaelenger/master

Major rewrite