small refactoring and style fixes

not tested :)