Mode refactoring
Merge pull request #181 from applicius/mode-refact

Mode refactoring