Refactor mod/lock.