Use the library bitcounter.
Use full values instead of counting bits. The memory savings aren't worth it.
Fix undo
Merge branch 'master' of https://github.com/tewalds/morat