Revert r271257 after several issues were pointed out.  An updated patch
will be committed at a later date.