Added some checks to make sure the imperfections of the protocol are avoided.