Merge change 1690 into donut

* changes:
  Rework some code so that it works the way it was supposed to work.