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.