Discard changes rewrite.

STUD-1860