some npe fixes