IndexService added.

Along with that code refactoring is also done.