Fixed some NPEs