Pathscanner refactor

Move PathScanner functionality into pbd/file_utils.h and a few fixes along the way.