Split code and data definitions
Fix errors with custom template