Fixed possible NPE during serialization
Merge pull request #2772 from lutovich/2.1-possible-npe-fix

Fixed possible NPE during serialization