Function removeLegacyState