Fixed polygon conversion to include sub-polygons

Past pull request had a bunch of debug code.