Minor error corrections and null checks