reorg and code cleanup