Bug 917761: Reland improvements for bug 678392 that were backed out along with bug 673875. r=smichaud,felipc