More comprehensive handling of error states