starting to integrate a synchronous version of the cloudant funcs (mostly working now)

fixed some bugs in the authentication process, though still not 100% correct