Refactored main app code so that user can pass different index and indexer instances