Minor modification to phase handling in khalil.py