Mm568

Fixed various bugs, see commit messages.
#568