Reimplemented imap in terms of Index.