Fix #907, remove two-way binding for dirty flag and simulate the same effect using a regular  function