Fixed possible nullpointexception.