major refactorings & code clean-up, added caching for retrieved locations