This PR adds the features that I asked about here. Please let me know what you think.
Thanks for the PR! I'll have a chance to review it hopefully soon.