position caching; refactoring to separate files