Reworked the way user functions are defined so that we pass them a context that includes the arguments and whether this is the first time they have been called