sets up server async channels and refactors api code