Clean index handling and bugfixing