some speed improvements