Minor bug fixes

Some issues I found while running the WZ code under static analysis.