improved debug logging