[WIP] Codegen errors

- [x] Remove duplication of interfaces
- [x] Fix fatal errors
@staabm no, the advantage is getting rid of any variables that aren't needed, reducing mutable state and therefore bug sources to be tracked down