clean up on state switch