Fixed logging to file and protocol deadlocks