de-deplicate names; plus refactor and comments