Fixed Emalloc to use a Markov chain