reorg and bug fix