Properly serialize nullable object id fields (fix #26)