Resurrected phase correction code from AgnGeneValidator class