Subtask of bug 14868.
Created attachment 16865 [details] Patch
Created attachment 16866 [details] Patch 2 Added a comment.
Comment on attachment 16866 [details] Patch 2 Oliver Hunt reviewed this.
Committed revision 27068.
Rolled this out because it didn't give me what I needed.