Fix crashes due to uninitialised or NULL variables

Saw a couple of crashes under Valgrind when I hadn't set PYTHON_PATH correctly.