Code cleanup, move some parts to model
Merge pull request #39 from madevr/madevr

Code cleanup, move some parts to model