fix defReplace
dont use for-in to iterate over map (sort relies on order)
update safeCopy to work with JSC
replace another for in
proper handling of primitive arrays, correct length of second iteration