Replaces .some() with .indexOf() where appropriate (fixed #825)

A couple of places there were some loops inside of loops when a simple `.indexOf` would suffice. Saves a couple hundred milliseconds on a big project.