Several fixes and tweaks