some logging and debuging

Need to fix synchronous write to asynchronous model.
And write data only when client is ready.