[core] Improved code generator