ENH: Better error handling