Fixed database setup and saving database variables to json