Refactored location stuff to separate database code from service code