Fixed bug that sometimes borked the linked list of monads

A variable on the stack was not being initialised, (and happened to always
point at a valid monad), and this was sometimes being attached onto the end of
the end of the linked list. That meant that monad_map() could never finish,
being stuck in an infinite loop of dead monads. But it's fixed now.

There is also some Ainu stuff in this commit, because I was working on that
when I noticed that there was a bug.