Backout 7f4f96dbf94f (bug 827172), 661847c6e48b (bug 827724), 00e357dd1458 (bug 827149) to fix the build on a CLOSED TREE