Added functions to check if a package is now useless

There are still a lots of things to debug, it may delete packages
still required.