Replace manual array copying with System.arraycopy