Performance improvement on count location data.

When cust_main has millions (In our case over 5million) rows this code was taking 5-15 seconds to process.  This made the cust_main->replace method extremly painful.

These modifications make the count take milliseconds.