added some null checking
more checking
fixes