Refactored search and GPS  position code.