Various fixes and tweaks