Various small speed-ups