Revert "It was working before, besides the idx bug. Revert after this commit?"

This reverts commit 6781e265e920d20be6b3531cb876b114f0d7a99b.
Before passing pointers in...