Replaced loop with System.arraycopy calls