Fixed database class and added queries