Fixed issues in code generation templates. added @functions