added get_and_flush_failed_items()