[ref] Added IsHandleNonNull() function and null checks.