Fixed nullpointer exceptions.