Fixed segfault, timeout handling and logging.