WIP.  Code cleanup.  fixme for ..._ref broken