fix bugs discovered in Firefox testing