Fix crashes and errors.