WIP.  Should be broken up into multiple commits.