Fix stack overflow in dependency list generation