WIP.  Refactor to remove earlier experiments.