Moved code around for Firefox