Fixed a number of issues related to the use of a spatial index for the join layer