Various enhancements to detect_phi.sas; a fair bit of reformatting.