/// <summary>
        /// Push a new state on the stack
        /// </summary>
        /// <returns>New state</returns>
        public State Push()
        {
            State state = new State();

            // Dequeue already suspended codes first so the correct order is maintained
            Queue <Code> alreadySuspendedCodes = new Queue <Code>(CurrentState.SuspendedCodes.Count);

            while (CurrentState.SuspendedCodes.TryDequeue(out Code suspendedCode))
            {
                alreadySuspendedCodes.Enqueue(suspendedCode);
            }

            // Suspend the already buffered codes
            foreach (Code bufferedCode in BufferedCodes)
            {
                _logger.Debug("Suspending code {0}", bufferedCode);
                CurrentState.SuspendedCodes.Enqueue(bufferedCode);
            }
            BytesBuffered = 0;
            BufferedCodes.Clear();

            // Add back any codes that were previously suspended
            while (alreadySuspendedCodes.TryDequeue(out Code suspendedCode))
            {
                CurrentState.SuspendedCodes.Enqueue(suspendedCode);
            }

            // Done
            Stack.Push(state);
            CurrentState = state;
            return(state);
        }
        /// <summary>
        /// Push a new state on the stack
        /// </summary>
        /// <returns>New state</returns>
        public State Push()
        {
            State state = new State();

            // Suspend the remaining buffered codes
            foreach (Code bufferedCode in BufferedCodes)
            {
                _logger.Debug("Suspending code {0}", bufferedCode);
                CurrentState.SuspendedCodes.Enqueue(bufferedCode);
            }
            BytesBuffered = 0;
            BufferedCodes.Clear();

            // Do not send codes to RRF until it has cleared its internal buffer
            IsBlocked = true;

            // Done
            Stack.Push(state);
            CurrentState = state;
            return(state);
        }