Various fixes and a very poor hack-up of indexing