switched from my own file tree traversal to ftw()
removed unused functions