Fixes bugs with location detection.