Updates

validPolygon and various code fixes/cleanup