refactor as per #38 and #37

everything works

used in concert with go-client's branch