Increase lookup performance by switching to SparseArray.