add dirty tracking and reverting