NPE fix + device rotation handling improvement