Remove two dead assigments (clang's scan-build)
Plug a potential memory leak (clang's scan-build).

Plus, put some more needed cleanups in the error paths.