Re-wrote codegen to output both header and source files. Fixes #1