Major refactoring
Merge pull request #1 from coopera/master

Major refactoring