add background tasks and fix scanning of directories