Phantom 1.7 fix

This is an option pull request that merges two other pull request to fix bugs. I am using this for my own projects.