fixed memory leaks that involve nulls