reorg some lib + cleanup