instead of arrays, use [table], that should help a fair bit.