added handling of undeliverable messages