Completed most functionality dealing with adding to and querying from the database