Revert "Revert "Small geometry fixes and Polygon joining""

This reverts commit 6c45baff8ffbd59fc7d1bcb66bf5f42a55d8561e.