Updates to phantomquail.js to make it work with the dev branch of Quail

This branch isn't ready to merge yet. I'm opening the PR to make the work visible to the KING team. It still needs some tweaks and cleanup.