Change arrays to linked arrays to ensure order preservation