A few other optimizations - avoid array copy, check index equality