Revert "Reverted last 3 commits and added simpler support for foreign Arrays."

This reverts commit 44e66dcf9dfce4d71e8f6e3368723241ff0f1bca.