remade modifications to phase.c for rawmac