Add a TODO: might need to flush pending state changes regularly