FIX: Fixed problem with generation of invalid codes in phase1 functions