Fixes problem with null comparisons and optional relationships
Merge pull request #579 from systay/optional-null-check

Fixes problem with null comparisons and optional relationships