Revert "Big, ugly merge. Something is almost definitely broken."

This reverts commit 7aad25e112c442113ad2ee0146e0610bd648b7e7, reversing
changes made to 4a1e96f6171883f18334f4560ab892ce9fb26da2.