Fix for Firebug (improved version of PR #86)

An improved version of PR #86, as discussed in the comments of that thread.
Fixes #86.