Made some non-semantic changes (explicit checks for NULL)