Fixed polygon conversion to include sub-polygons

This should fix the build problems.