Made postgis uploads more efficient

some refactoring