Index methods

Hi. There was already a 'put' method in IndexWrapper to manually add an element to the index, but there was no corresponding 'remove' method. I've added that method in this pull request. I also did some light refactoring to dry up the code.