Much cleaner and more efficient zipWithIndex based on Matei's suggestions