Added REST support and refactored indexing