Refactored db-api connections
Added agent queries