Tweaked error handlers to be more tolerant and autodetect apps.