fixed some nasty NPEs