Improve the handling of critical state