major refactoring
leftovers fixing
Merge pull request #40 from louridas/master

major refactoring