more code reorg/documentation