huge code refactoring
Merge pull request #6 from rgex/master

huge code refactoring