Fix index order in certain corner case

Closes #93.