API generation:

Includes some code cleaning