some reorg and fixes