backout 9251ac84b3e4 and 6c4d96765e74 (Bug 1057487 and 1046537)