Better handling of directory errors