Fixes through scan build

compiling with clang reveals a lot of "unused variables" -- removed some

compiling with scan-build revealed one "possible null reference" which is, granted, rather obscure -- added a "throw"