Fixed memory errors in logging