Bug fix and improvement of protocol