Issue #247: portability changes for leak detection