Various speed improvements and tweaks