Handle errors more gracefully, credit: Philartphoto
Merge branch 'Philartphoto'