did you skip fixing any warnings?
I'm guessing clipped surfaces, or portalling errors.
I think structure->surfaces is null, and doesn't have a count property, causing exception, so it's some kind of structure related problem