indexing stuff was completely wrong, mostly fixed now