  The first supernovae enrich the previously pristine gas with metals, out of
which the next generation of stars form. Based on hydrodynamical simulations,
we develop a new stochastic model to predict the metallicity of star-forming
gas in the first galaxies. On average, in internally enriched galaxies, the
metals are well mixed with the pristine gas. However, in externally enriched
galaxies, the metals can not easily penetrate into the dense gas, which yields
a significant metallicity difference between the star-forming and average gas
inside a halo. To study the consequences of this effect, we apply a
semi-analytical model to Milky Way-like dark matter merger trees and follow
stellar fossils from high redshift until the present day with a novel realistic
metal mixing recipe. We calibrate the model to reproduce the metallicity
distribution function (MDF) at low metallicities and find that a primordial IMF
with slope of $\mathrm{d}N/\mathrm{d}M \propto M^{-0.5}$ from $2 Msun$ to $180
Msun$ best reproduces the MDF. Our improved model for inhomogeneous mixing can
have a large impact for individual minihalos, but does not significantly
influence the modelled MDF at [Fe/H]$\gtrsim -4$ or the best-fitting Pop~III
IMF.

Astrophysics of Galaxies