Replaced all the external calls to `grep --count -e ^\.M` with pattern matching. Cleaner, easier to read, should be faster, did no benchmark on this one.