Get rid of unsafe indexing

Unsafe indexing is replaced by ImmutableEqVector::position_elem() and a
few branches have been eliminated.

The performance is about the same as for unsafe indexing.