fixed null pointer errors.

Change-Id: I89ba110cb08bbe6fb8f0644d906bb26ccf739866