Functions now write output into parameter

Only create a new output if it is null, otherwise write result into the
output parameter