Made the database class keep track of its own connection