Update the API, adding extern functions
Move the generate code to another file