About too refactor old code generation scheme, see function generation slides in beam-extapi.doc