implements api code generation (instead of at runtime); adds more

documentation