Some null checks here and there.