- fixed some stuff considering the closing of the database