Refactor config and index files