Minor tweaks to reduce memory leaks.