Added handling of dirtying in materializing state

We mark the record as dirtyWhileMaterialzing, and then transition to
loaded.updated once we are on finishedMaterializing.