several fixes and tweaks