Fixes #164. Fixes Bug 1041234; r? @davidbgk

See https://bugzilla.mozilla.org/show_bug.cgi?id=1041234