Code clean up and reorg, stage one.