Various updates and fixes to get the spatial querying working.