Made the protcol much more relaible and fixed the SOP code.