Backout 36ffb3c3ae85, will re-apply latest
Backout 014c973d8bbe, will re-apply latest
Bug 945192. r=rstrong
imported patch 1.diff