Added ability to count the usage of each library. A few bug fixes too