Assorted fixes in preparation for Safari support