apply-gen now properly handles multiple functions