Attempt to fix valgrind warnings about reading uninitialised memory