The output is now reproducible.
I'm sorry for a bit messy MR but this is a result of debugging.
/cc @jchapman @tdado