Complete rewrite of client