Better error handling with resources.