Fix implementation of a number of primitive functions