various fixes and tweaks