Various bugfixes to MMBot.

Commit messages should be self-explanatory.