Changes needed for making it work on PhantomJS.