Back out bug 972591 (4ca2f958008b and 8048c03516b1) for probably causing Valgrind leaks.
Merge backout, a=bustage fix