Fix some problems with the database

Added a new Thread class for making the graph