Clean up error handling quite a bit