Cleaning up error handling a little.