Major refactoring: moved most of the functionality into a class
Merge pull request #1 from mpath/working

Major refactoring: moved most of the functionality into a class