Clean up some error handling