public void ReadMsg(BitStream stream)
        {
            if (_messageCount + 1 > _maxMessageCount)
            {
                Debug.WriteLine("hit MaxMessageCOunt abourting");

                throw new ApplicationException();
            }

            _messageCount++;
            while (stream.Length - stream.Cursor > 2)
            {
                _bs.Add(stream.ReadBool());

                //removing DebugListeners to ignore Debug.Assert's while trying to parse with current length
                TraceListener[] listeners = new TraceListener[Debug.Listeners.Count];
                Debug.Listeners.CopyTo(listeners, 0);
                Debug.Listeners.Clear();

                try
                {
                    List <INetMessage> netMessages = NetMessageCoder.Decode(stream.Clone());
                    AddCandidates(netMessages);
                }
                catch (StackOverflowException)
                {
                    Debug.WriteLine("hit StackOverflowException aborting");
                    break;
                }
                catch (OverflowException exception)
                {
                    Debug.WriteLine("hit OverflowException aborting");
                    break;
                }
                catch (Exception exception)
                {
                }
                finally
                {
                    Debug.Listeners.AddRange(listeners);
                }
            }

            _bestCandidate = _candidates
                             .Where(c => c.Messages.Count > 0)
                             .Where(c => c.ChildDebugMessageLength != int.MaxValue)
                             .OrderByDescending(c => c.Messages.Count)
                             .ThenBy(c => c.ChildDebugMessageLength)
                             .FirstOrDefault();

            if (_bestCandidate == null)
            {
                Debug.WriteLine("Unknown message: no candidate");
            }
            else
            {
                Debug.WriteLine("Unknown message: {0} bits long with best candidate having {1} unknown bits ", _bestCandidate.FieldLength, _bestCandidate.ChildDebugMessageLength);
            }

            _messageCount--;
        }