mild refactor and remove dead code