Merge pull request #40 from korczis/refactor

Lot of refactoring