adding AMD support and fixing the potential modification to `Array`