Some speed improvements