Fixed performance regression.

See discussion under #157.