More error handling and logging.