Query files and directories received as parameters. Some cleanup