Various performance hacks and clean-ups