Avoid illegal state exception.