Several small fixes, mostly related to spatial searches.