Make cleanUpLocation() a self-contained function.