Redid how state clearing is handled