Safari and Firefox browser compatibility

This PR isn't *quite* finished - there's still a bit more to be done for Firefox compatibility. OK to start reviewing, but don't merge until I say it's ready...
a comment here on why 4/5 would be nice