A few speed improvements