optimized file and directory watching