WIP #9 and #16. They are closely related right now.