#87525R: refactoring and minor changes
#8725R: fix collapsed polygons by ST_simplify in postgis