Memory leaks and variable initialisation fixes, from instrumenting tools.