Fix bug with Variable _MEM

In order to get the correct unique, global index, all variables need
to be listed in a flat memory.