Work towards making threading more worth it

This commit compiles and works but the resulting files are not correct.
Threads + recursive still doesn't work.
Fix file output, threads are broken
Fix threading

First benchmarks show this new implementation is a bit more than twice
as slow though.
Change threading organisation

Threads are now created for each file_action or dir_action, not for each
file or directory. This should help fix recursion with threading in the
future.
Fix recursive search and threading

Introduces a garbage collector to eliminate memory corruption when
searching directories recursively.
Add ability to specify the pattern to be recognised