fixed various obscure NPEs