global: graph and stats

* Adds stats for projects.

* Changes Stats structure.

* Optimizes the code.

* Simplifies part of the code.