Builtin function implementations and cleanup in the code generator