added logging and fixed the way cap treats the number of needed files