added logging
refactored more stuff
Merge branch 'develop'