Start to rewrite client script to incporporate logging. TODO: not
finished