Refactor negotiator code