Fixed some memory errors in client code.