Fix nasty performance problem