I took a first shot at this in #2266. Can you guys take a look and let me know what you think?