Finished first stage refactoring of Api, abstracted querying into separate db class