What I got so far. Theoretically works for arrays now. May be completely
wrong.