improvements to polygons and some basic  spaning and file stuff