Add some missing initialisation, and fix a handful benign resource leaks (including some false positives).