Implement (most of) #2211