Refactored indexer. Moved index writer to separate lib