Fixing some == vs === stuff, checking for undefined rather than null.