Updated debugging messages to be written in a single fprintf() call in an attempt to avoid having them intermingled when written from multiple threads