Fix issues reported in PR for leaks branch.