Some null-checking to remove errors in IE