Fix a couple more bugs in the phi construction by pulling in code that does