If there are duplicate positions, won't terrain and wallPositions be out of sync?  Wouldn't we have to remove duplicates in terrain as well.