More refactoring

Still no tail recursion
Not sure, if tail recursion is applicable, since the dict values need
to be written not as intermediary results, but as final counts