Additional checks for SDK return values, fixes NPE.