Better error handling if something goes wrong.