adding change tracking on flag and some general clean up