Fix depencency count bug.

It was overriding the result.
Improve variable name.

‘package’ is reserved.
Add more trace logs.