Hoist the operators out of the for loop

See #66.