code reorg and some other stuff