Fix cocurrency issues with debug output