little refactoring and some more shallow fixes