Fix NPE in CheckSideEffects

Even after testing, my last commit created an NPE in certain cases. This should correct the issue.