improved protocol robustness, logging added