Improve mark-and-sweep array patching to include nested arrays. Code needs to be refactored, but works