Fixing crashing issue related to state-saving on MSV