Replaced System.arraycopy with reflective array access.
This solves ArrayStoreExceptions that would otherwise occur with a primitive array.