Use `IndexedSeq` instead of `Seq` for faster indexed access. Cleanup code.