Issue 2094

This builds on previous work by @dweeezil in #2097 and should be ready to be merged.