Revised error handling to something a bit more sane.