Replace array lookup with object lookup, speeding things up significantly