Fixed crashes and image corruption