Make sure we do not loose the key when flatening the array
This should fix #1599