Tag Machines for Modeling Heterogeneous Systems