Fixed nullPointerExceptions