DB improvements

Improved the issues with the database.