This reverts "Attempt to optimize file counting." and related commits. (commit c257429c561af8b99bb0a0daa65871a80a9fedb2)