Further changes to get rid of null pointer errors.