Fixed possible nullpointerexception.