code reorg
more reorg and cleanup