Fixed arraycopy bug