[WIP] Codegen errors

- [x] Remove duplication of interfaces
- [x] Fix fatal errors
@Ocramius it's needed because it's called outside the classe scope