fix nullpointer exceptions

Change-Id: I8cebe692424f1af78452cd10b7767d5a2612148a