refactored codegen
refactored packet code gen, updated templates