Add m command.
minor optimizations to m and mates