Show idx calculation for insert. Closes #2. Also some refactoring.