Prevent some crashes and assertions.