Improve logging of protocol errors
Fix read buffer filling