Restructure module to put copyBySchema into a separate module
Added handling of arrays (untested)