Performance fixes and tweaks