fix a couple null pointer bugs