some refactoring and cleaning up
Merge remote-tracking branch 'upstream/master'
cleaning