Move checking for quirks mode to the utils.js and other fixes