diff --git a/gst/ccdec/gstccdec.c b/gst/ccdec/gstccdec.c
index 5710cc1..dbbabc4 100644
--- a/gst/ccdec/gstccdec.c
+++ b/gst/ccdec/gstccdec.c
@@ -53,16 +53,14 @@
 #endif
 
 #include <gst/gst.h>
+#include <gst/base/gstbitreader.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include "gstccdec.h"
 #include "gstcea708dec.h"
 
-#define GST_LICENSE "LGPL"
-
 #undef SUPPORT_CEA608
-#undef STANDALONE_ELEMENT
 
 #define GST_CAT_DEFAULT gst_cc_decoder_debug
 #define gst_cc_decoder_parent_class parent_class
@@ -91,49 +89,8 @@ GST_STATIC_PAD_TEMPLATE ("cea708_src",
     GST_PAD_SOMETIMES,
     GST_STATIC_CAPS ("text/x-cea708-raw"));
 
-typedef enum
-{
-  CCTYPE_608_CC1 = 0,
-  CCTYPE_608_CC2,
-  CCTYPE_708_ADD,
-  CCTYPE_708_START,
-} DtvccType;
-
-#define NUM_608_CCTYPES 2
 #define CCTYPE_PAD_NAME(cc_type) ((cc_type <= CCTYPE_608_CC2) ? "cea608_srcpad" : "cea708_srcpad")
 
-/* This element's private data */
-struct _GstCcDecoder
-{
-  /* Storage for parent Element */
-  GstElement element;
-
-  /* Element pads */
-  GstPad *sinkpad;
-  GstPad *cea608_srcpad;
-  GstPad *cea708_srcpad;
-  gboolean need_no_more_pads;
-
-  /* input data storage */
-  GSList *data_list;
-
-  /* Output data storage */
-  /* There are two possible 608 streams */
-  gint16 cea608_index[NUM_608_CCTYPES];
-  gint16 cea708_index;
-  guint8 cea608_buffer[NUM_608_CCTYPES][DTVCC_LENGTH];
-  guint8 cea708_buffer[DTVCC_LENGTH];
-
-  /* holds the most recent segment data for a new segment event */
-  GstSegment segment;
-};
-
-struct _GstCcDecoderClass
-{
-  /* Storage for parent ElementClass */
-  GstElementClass parent_class;
-};
-
 GST_DEBUG_CATEGORY_STATIC (gst_cc_decoder_debug);
 
 G_DEFINE_TYPE (GstCcDecoder, gst_cc_decoder, GST_TYPE_ELEMENT);
@@ -154,7 +111,7 @@ gst_cc_decoder_class_init (GstCcDecoderClass * klass)
   gobject_klass = G_OBJECT_CLASS (klass);
   gstelement_klass = GST_ELEMENT_CLASS (klass);
 
-  gobject_klass->dispose = GST_DEBUG_FUNCPTR (gst_cc_decoder_dispose);
+  gobject_klass->dispose = gst_cc_decoder_dispose;
 
   /* Pads */
   gst_element_class_add_pad_template (gstelement_klass,
@@ -169,13 +126,7 @@ gst_cc_decoder_class_init (GstCcDecoderClass * klass)
       "Decoder", "closed caption decoding element",
       "CableLabs RUIH-RI Team <ruihri@cablelabs.com>");
 
-#ifndef STANDALONE_ELEMENT
   GST_DEBUG_CATEGORY_INIT (gst_cc_decoder_debug, "ccdec", 0, "CC Decoder");
-#endif
-#ifdef DEBUG_ELEMENT_SIZE
-  g_message ("%s %d = sizeof(_GstCcDecoder)\n", __func__,
-      sizeof (struct _GstCcDecoder));
-#endif
 }
 
 static void
@@ -183,12 +134,7 @@ gst_cc_decoder_dispose (GObject * object)
 {
   GstCcDecoder *decoder = GST_CC_DECODER (object);
 
-  while (decoder->data_list) {
-    gst_buffer_unref (decoder->data_list->data);
-    decoder->data_list = g_slist_remove (decoder->data_list,
-        decoder->data_list->data);
-  }
-
+  g_slist_free_full (decoder->data_list, (GDestroyNotify) gst_buffer_unref);
   GST_INFO_OBJECT (decoder, "complete");
   G_OBJECT_CLASS (gst_cc_decoder_parent_class)->dispose (object);
 }
@@ -197,23 +143,16 @@ static void
 gst_cc_decoder_init (GstCcDecoder * decoder)
 {
   GST_DEBUG_OBJECT (decoder, "called");
-  decoder->data_list = NULL;
   gst_segment_init (&decoder->segment, GST_FORMAT_UNDEFINED);
 
-  // Add sink pad
+  /* Add sink pad */
   decoder->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
   gst_pad_set_event_function (decoder->sinkpad, gst_cc_decoder_sink_events);
   gst_pad_set_chain_function (decoder->sinkpad, gst_cc_decoder_chain);
   gst_element_add_pad (GST_ELEMENT (decoder), decoder->sinkpad);
   GST_INFO_OBJECT (decoder, "sink pad added to decoder");
 
-  decoder->cea608_srcpad = NULL;
-  decoder->cea708_srcpad = NULL;
   decoder->need_no_more_pads = TRUE;
-  decoder->cea708_index = 0;
-  for (size_t i = 0; i < NUM_608_CCTYPES; ++i) {
-    decoder->cea608_index[i] = 0;
-  }
 }
 
 static gboolean
@@ -235,20 +174,17 @@ gst_cc_decoder_sink_events (GstPad * pad, GstObject * parent, GstEvent * event)
 static gboolean
 gst_cc_decoder_send_new_segment (GstCcDecoder * decoder, GstPad * srcpad)
 {
-  if (NULL != decoder && NULL != srcpad) {
-    GstEvent *event;
-
-    if (decoder->segment.format == GST_FORMAT_UNDEFINED) {
-      GST_WARNING_OBJECT (decoder, "No segment received before first buffer");
-    }
+  GstEvent *event;
 
-    GST_INFO_OBJECT (decoder, "Sending segment %" GST_SEGMENT_FORMAT,
-        &decoder->segment);
-    event = gst_event_new_segment (&decoder->segment);
-    return gst_pad_push_event (srcpad, event);
+  if (decoder->segment.format == GST_FORMAT_UNDEFINED) {
+    GST_WARNING_OBJECT (decoder, "No segment received before first buffer");
+    return FALSE;
   }
 
-  return FALSE;
+  GST_INFO_OBJECT (decoder, "Sending segment %" GST_SEGMENT_FORMAT,
+      &decoder->segment);
+  event = gst_event_new_segment (&decoder->segment);
+  return gst_pad_push_event (srcpad, event);
 }
 
 static GstPad *
@@ -291,8 +227,8 @@ gst_cc_decoder_get_srcpad (GstCcDecoder * decoder, DtvccType cc_type)
         gst_pad_create_stream_id_printf (*pad, GST_ELEMENT (decoder), NULL);
     gst_pad_push_event (*pad, gst_event_new_stream_start (start_id));
     g_free (start_id);
-    gst_element_add_pad (GST_ELEMENT (decoder), *pad);
     gst_cc_decoder_send_new_segment (decoder, *pad);
+    gst_element_add_pad (GST_ELEMENT (decoder), *pad);
   }
   return *pad;
 }
@@ -366,9 +302,9 @@ gst_cc_decoder_user_data_decode (GstCcDecoder * decoder, UserData * user_data)
   guint8 cc_valid;
   guint8 cc_data[2];
 
-  // we need at least 6 bytes of data to process 1 ATSC packet
+  /* we need at least 6 bytes of data to process 1 ATSC packet */
   if (user_data->length < 6) {
-    GST_ERROR ("ATSC user data packet underflow!");
+    GST_ERROR_OBJECT (decoder, "ATSC user data packet underflow!");
     return;
   }
 
@@ -376,7 +312,7 @@ gst_cc_decoder_user_data_decode (GstCcDecoder * decoder, UserData * user_data)
       user_data->tr, user_data->timestamp, user_data->data[4]);
 
   if (ATSC_USER_DATA_TYPE (user_data->data) == ATSC_USER_DATA_TYPE_CCDATA) {
-    // skip the 4 byte UserData header and the ATSC type byte
+    /* skip the 4 byte UserData header and the ATSC type byte */
     index = 5;
     temp = user_data->data[index++];
     process_em_data_flag = (temp & 0x80) ? TRUE : FALSE;
@@ -388,13 +324,13 @@ gst_cc_decoder_user_data_decode (GstCcDecoder * decoder, UserData * user_data)
         "process_cc_df=%d additional_df=%d cc_count=%d", process_em_data_flag,
         process_cc_data_flag, additional_data_flag, cc_count);
 
-    em_data = user_data->data[index++]; // not used currently
+    em_data = user_data->data[index++]; /* not used currently */
     (void) em_data;
 
     if (process_cc_data_flag) {
-      // verify ther is enough data in the packet!
+      /* verify ther is enough data in the packet! */
       if (user_data->length < (cc_count * 3)) {
-        GST_ERROR ("DTVCC user data packet underflow!");
+        GST_ERROR_OBJECT (decoder, "DTVCC user data packet underflow!");
         return;
       }
 
@@ -409,7 +345,7 @@ gst_cc_decoder_user_data_decode (GstCcDecoder * decoder, UserData * user_data)
             "cc_data[0]=0x%X cc_data[1]=0x%X",
             i, cc_valid, cc_type, cc_data[0], cc_data[1]);
 
-        // accumulate dvtcc packet
+        /* accumulate dvtcc packet */
         switch (cc_type) {
           case CCTYPE_608_CC1:
           case CCTYPE_608_CC2:
@@ -419,8 +355,9 @@ gst_cc_decoder_user_data_decode (GstCcDecoder * decoder, UserData * user_data)
                   if ((cc_data[i] < ' ') || (cc_data[i] > '~')) {
                     gst_cc_decoder_process_packet (decoder, user_data, cc_type);
                   }
-                  decoder->cea608_buffer[cc_type][decoder->
-                      cea608_index[cc_type]++] = cc_data[i];
+                  decoder->
+                      cea608_buffer[cc_type][decoder->cea608_index[cc_type]++] =
+                      cc_data[i];
                 }
               } else {
                 GST_ERROR_OBJECT (decoder, "cea608_buffer[%d] overflow!",
@@ -433,10 +370,10 @@ gst_cc_decoder_user_data_decode (GstCcDecoder * decoder, UserData * user_data)
           case CCTYPE_708_START:
             if (cc_valid) {
               if (cc_type == CCTYPE_708_START) {
-                // The previous packet is complete
+                /* The previous packet is complete */
                 gst_cc_decoder_process_packet (decoder, user_data, cc_type);
               }
-              // Add on to the current DTVCC packet
+              /* Add on to the current DTVCC packet */
               if (decoder->cea708_index <= DTVCC_LENGTH - 2) {
                 decoder->cea708_buffer[decoder->cea708_index++] = cc_data[0];
                 decoder->cea708_buffer[decoder->cea708_index++] = cc_data[1];
@@ -444,8 +381,8 @@ gst_cc_decoder_user_data_decode (GstCcDecoder * decoder, UserData * user_data)
                 GST_ERROR_OBJECT (decoder, "cea708_buffer overflow!");
               }
             } else if (cc_type == CCTYPE_708_ADD) {
-              // This packet should be ignored, but if there is a current
-              // DTVCC packet then this is the end.
+              /* This packet should be ignored, but if there is a current */
+              /* DTVCC packet then this is the end. */
               gst_cc_decoder_process_packet (decoder, user_data, cc_type);
             }
             break;
@@ -463,12 +400,12 @@ gst_cc_decoder_prime_decode_chain (GstCcDecoder * decoder, UserData * user_data)
   DtvccType cc_type;
 
   if (ATSC_USER_DATA_TYPE (user_data->data) == ATSC_USER_DATA_TYPE_CCDATA) {
-    // skip the 4 byte UserData header and the ATSC type byte
+    /* skip the 4 byte UserData header and the ATSC type byte */
     index = 5;
     process_cc_data_flag = (user_data->data[index] & 0x40) ? TRUE : FALSE;
 
     if (process_cc_data_flag) {
-      // skip the EM data and to the CC packets
+      /* skip the EM data and to the CC packets */
       index = 13;
       cc_type = user_data->data[index] & CCTYPE_TYPE_MASK;
 
@@ -476,7 +413,7 @@ gst_cc_decoder_prime_decode_chain (GstCcDecoder * decoder, UserData * user_data)
         case CCTYPE_608_CC1:
         case CCTYPE_608_CC2:
           if (NULL == decoder->cea608_srcpad) {
-            // send a DTVCC NULL to complete the pipeline instantiation...
+            /* send a DTVCC NULL to complete the pipeline instantiation... */
             decoder->cea608_index[cc_type] = 0;
             decoder->cea608_buffer[cc_type][decoder->cea608_index[cc_type]++] =
                 0x80;
@@ -488,7 +425,7 @@ gst_cc_decoder_prime_decode_chain (GstCcDecoder * decoder, UserData * user_data)
         case CCTYPE_708_ADD:
         case CCTYPE_708_START:
           if (NULL == decoder->cea708_srcpad) {
-            // send a DTVCC NULL to complete the pipeline instantiation...
+            /* send a DTVCC NULL to complete the pipeline instantiation... */
             decoder->cea708_index = 0;
             decoder->cea708_buffer[decoder->cea708_index++] = 0x02;
             decoder->cea708_buffer[decoder->cea708_index++] = 0x22;
@@ -507,23 +444,21 @@ static gint
 gst_cc_decoder_buflist_compare (gconstpointer element_A,
     gconstpointer element_B)
 {
-  UserData *user_data_A = NULL;
-  UserData *user_data_B = NULL;
   GstMapInfo elt_map_A = { 0 };
   GstMapInfo elt_map_B = { 0 };
   gint ret_val = 0;
 
   gst_buffer_map (GST_BUFFER (element_A), &elt_map_A, GST_MAP_READ);
-  user_data_A = (UserData *) elt_map_A.data;
   gst_buffer_map (GST_BUFFER (element_B), &elt_map_B, GST_MAP_READ);
-  user_data_B = (UserData *) elt_map_B.data;
 
-  if (user_data_A->tr < user_data_B->tr) {
+  if (((UserData *) elt_map_A.data)->tr < ((UserData *) elt_map_B.data)->tr) {
     ret_val = -1;
-  } else if (user_data_A->tr > user_data_B->tr) {
+  } else if (((UserData *) elt_map_A.data)->tr >
+      ((UserData *) elt_map_B.data)->tr) {
     ret_val = 1;
   } else {
-    GST_ERROR ("duplicated TR(%d) w/o GOP processing!", user_data_B->tr);
+    GST_ERROR ("duplicated TR(%d) w/o GOP processing!",
+        ((UserData *) elt_map_B.data)->tr);
   }
 
   gst_buffer_unmap (GST_BUFFER (element_A), &elt_map_A);
@@ -623,41 +558,46 @@ gst_cc_decoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
   GstMapInfo data_map = { 0 };
   guint8 tr0_count;
   gint8 previous_tr;
+  GstBitReader gbr;
+  guint32 ud_id = 0;
 
   gst_buffer_map (buf, &buf_map, GST_MAP_READ);
   user_data = (UserData *) buf_map.data;
+  gst_bit_reader_init (&gbr, user_data->data, buf_map.size - sizeof (UserData));
+  gst_bit_reader_get_bits_uint32 (&gbr, &ud_id, 32);
 
-  if (g_str_has_prefix ((const gchar *) (user_data->data), "GA94") ||
-      g_str_has_prefix ((const gchar *) (user_data->data), "DTG1")) {
+  /* "GA94" or "DTG1" are the allowed UD identifiers for ATSC A/53 part 4 */
+  if ((ud_id == 0x47413934) || (ud_id == 0x44544731)) {
     gst_cc_decoder_prime_decode_chain (decoder, user_data);
     decoder->data_list =
         g_slist_insert_sorted (decoder->data_list, buf,
         gst_cc_decoder_buflist_compare);
     GST_LOG_OBJECT (decoder, "inserted: %c%c%c%c", user_data->data[0],
         user_data->data[1], user_data->data[2], user_data->data[3]);
-    gst_buffer_unmap (buf, &buf_map);
-  } else if (g_str_has_prefix ((const gchar *) (user_data->data), "GOP\0")) {
-    // New GOP header received, process existing array of user data packets
+    /* ref buf here for code consistency below (unmap unref at exit) */
+    gst_buffer_ref (buf);
+  } else if (ud_id == 0x474F5000) {   /* "GOP\0" */
+    /* New GOP header received, process existing array of user data packets */
     for (tr0_count = 0, previous_tr = -1; NULL != decoder->data_list;) {
       gst_buffer_map (decoder->data_list->data, &data_map, GST_MAP_READ);
       user_data = (UserData *) data_map.data;
 
-      // Validate the CC data stream, it should be in sorted (based on
-      // the temporal reference (tr)) and contiguous.
+      /* Validate the CC data stream, it should be in sorted (based on */
+      /* the temporal reference (tr)) and contiguous. */
       if (user_data->tr == 0) {
         tr0_count++;
 
         if (tr0_count > 1) {
-          // If a GOP is missed, and two GOP sets of frames are interleaved in
-          // the sorted list caption data will be currupt until the next cycle.
+          /* If GOP is missed, and two GOP sets of frames are interleaved in */
+          /* the sorted list caption data will be currupt until next cycle. */
           GST_WARNING_OBJECT (decoder, "Missed previous GOP processing!");
         }
       } else if ((user_data->tr - previous_tr) > 1) {
-        // Missing frames may result in missing caption characters
+        /* Missing frames may result in missing caption characters */
         GST_WARNING_OBJECT (decoder, "Missing video frame %d!",
             user_data->tr - 1);
       } else if (user_data->tr == previous_tr) {
-        // Most likely caused by a missing GOP
+        /* Most likely caused by a missing GOP */
         GST_WARNING_OBJECT (decoder, "Duplicate video frame %d", user_data->tr);
       }
 
@@ -674,40 +614,18 @@ gst_cc_decoder_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
       decoder->data_list = g_slist_remove (decoder->data_list,
           decoder->data_list->data);
 
-      // we've seen a whole GOP's worth of CC data, emit no_more_pads if needed
+      /* we've seen a GOP's worth of CC data, emit no_more_pads if needed */
       if (decoder->need_no_more_pads) {
         decoder->need_no_more_pads = FALSE;
         gst_element_no_more_pads (GST_ELEMENT (decoder));
         GST_INFO_OBJECT (decoder, "no_more_pads");
       }
     }
-
-    gst_buffer_unmap (buf, &buf_map);
-    gst_buffer_unref (buf);
   } else {
     GST_ERROR_OBJECT (decoder, "unknown data, slist:%p", decoder->data_list);
-    gst_buffer_unmap (buf, &buf_map);
-    gst_buffer_unref (buf);
   }
 
+  gst_buffer_unmap (buf, &buf_map);
+  gst_buffer_unref (buf);
   return ret_val;
 }
-
-#ifdef STANDALONE_ELEMENT
-static gboolean
-decoder_init (GstPlugin * plugin)
-{
-  gboolean res = FALSE;
-
-  GST_DEBUG_CATEGORY_INIT (gst_cc_decoder_debug, "ccdec", 0, "CC Decoder");
-  res = gst_element_register (plugin, "ccdec",
-      GST_RANK_PRIMARY, GST_TYPE_CC_DECODER);
-  return res;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
-    GST_VERSION_MINOR,
-    ccdecbad,
-    "ccdec",
-    decoder_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
-#endif
diff --git a/gst/ccdec/gstccdec.h b/gst/ccdec/gstccdec.h
index 70f9f97..cb8d80b 100644
--- a/gst/ccdec/gstccdec.h
+++ b/gst/ccdec/gstccdec.h
@@ -67,6 +67,48 @@ typedef struct
   guint8 data[0];
 } UserData;
 
+typedef enum
+{
+  CCTYPE_608_CC1 = 0,
+  CCTYPE_608_CC2,
+  CCTYPE_708_ADD,
+  CCTYPE_708_START,
+} DtvccType;
+
+#define NUM_608_CCTYPES 2
+
+/* This element's private data */
+struct _GstCcDecoder
+{
+  /* Storage for parent Element */
+  GstElement element;
+
+  /* Element pads */
+  GstPad *sinkpad;
+  GstPad *cea608_srcpad;
+  GstPad *cea708_srcpad;
+  gboolean need_no_more_pads;
+
+  /* input data storage */
+  GSList *data_list;
+
+  /* Output data storage */
+  /* There are two possible 608 streams */
+  gint16 cea608_index[NUM_608_CCTYPES];
+  gint16 cea708_index;
+  guint8 cea608_buffer[NUM_608_CCTYPES][DTVCC_LENGTH];
+  guint8 cea708_buffer[DTVCC_LENGTH];
+
+  /* holds the most recent segment data for a new segment event */
+  GstSegment segment;
+};
+
+struct _GstCcDecoderClass
+{
+  /* Storage for parent ElementClass */
+  GstElementClass parent_class;
+};
+
 
 typedef struct _GstCcDecoder GstCcDecoder;
 typedef struct _GstCcDecoderClass GstCcDecoderClass;
diff --git a/gst/ccdec/gstcea708dec.c b/gst/ccdec/gstcea708dec.c
index 8429a01..6a99796 100644
--- a/gst/ccdec/gstcea708dec.c
+++ b/gst/ccdec/gstcea708dec.c
@@ -65,19 +65,14 @@
 #include "gstccdec.h"
 #include "gstcea708dec.h"
 
-#define GST_LICENSE "LGPL"
-
 #define GST_CAT_DEFAULT gst_cea708dec_debug
 #define gst_cea708dec_parent_class parent_class
 
 
-// If the following line is defined, WebVTT line positions will be in percent,
-// otherwise line positions will be in integer line numbers
+/* If the following line is defined, WebVTT line positions will be in percent,
+ * otherwise line positions will be in integer line numbers */
 #undef WEBVTT_LINE_PERCENT
 
-#undef STANDALONE_ELEMENT
-
-
 #ifdef WEBVTT_LINE_PERCENT
 #define WEBVTT_FORMAT "%s --> %s %s line:%d%% position:%d%%\n"
 #else
@@ -101,9 +96,9 @@
 #define TS_SECS(x)  ((x) * 90000)
 #define TS_MSEC(x)  ((x) * 90)
 
-// 708 colors are defined by 2 bits each for R,G,&B for a total of 64 color combinations
+/* 708 colors are defined by 2 bits each for R,G,&B for a total of 64 color combinations */
 static const gchar *color_names[] = {
-  "black",                      // 0
+  "black",                      /* 0 */
   "color1",
   "color2",
   "color3",
@@ -189,57 +184,17 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SOMETIMES,
     GST_STATIC_CAPS ("text/vtt"));
 
-/* This element's private data */
-struct _GstCea708Dec
-{
-  /* Storage for parent Element */
-  GstElement element;
-
-  /* Element pads */
-  GstPad *sinkpad;
-  GstPad *srcpad;
-
-  /* output data storage */
-  GSList *text_list;
-
-  // simulation of 708 CC windows
-  cea708Window *cc_windows[MAX_708_WINDOWS];
-  guint8 current_window;
-
-  gint8 output_ignore;          // a counter used to ignore bytes in CC text stream following commands
-
-  guint64 current_time;         // most recent timestamp from userdata
-
-  // desired_service selects the service that will be decoded. If desired_service = -1 (default) no
-  // decoding based on service number will occur. Service #0 is reserved, and the valid range of
-  // service numbers is 1-6 with 1 being primary caption service and 2 being the secondary language
-  // service.
-  gint8 desired_service;
-
-  // previous_desired_service is used to detect a change in the desired service. When changing service
-  // number, only change the desired_service variable
-  gint8 previous_desired_service;
-
-  /* holds the most recent segment data for a new segment event */
-  GstSegment segment;
-};
-
-struct _GstCea708DecClass
-{
-  /* Storage for parent ElementClass */
-  GstElementClass parent_class;
-};
-
 
 
 GST_DEBUG_CATEGORY_STATIC (gst_cea708dec_debug);
 
 G_DEFINE_TYPE (GstCea708Dec, gst_cea708dec, GST_TYPE_ELEMENT);
 
-static void gst_cea708dec_send_text (GstObject *, GSList **, gint, GstPad *);
+static GstFlowReturn gst_cea708dec_send_text (GstObject *, GSList **, gint,
+    GstPad *);
 static gint gst_cea708dec_text_list_add (GstObject *, GSList **, gint,
     const gchar *, ...);
-static gboolean gst_cea708dec_add_text_srcpad (GstCea708Dec * decoder);
+static void gst_cea708dec_add_text_srcpad (GstCea708Dec * decoder);
 static void gst_cea708dec_dispose (GObject * object);
 static gboolean gst_cea708dec_sink_events (GstPad * pad,
     GstObject * parent, GstEvent * event);
@@ -257,7 +212,7 @@ gst_cea708dec_class_init (GstCea708DecClass * klass)
   gobject_klass = G_OBJECT_CLASS (klass);
   gstelement_klass = GST_ELEMENT_CLASS (klass);
 
-  gobject_klass->dispose = GST_DEBUG_FUNCPTR (gst_cea708dec_dispose);
+  gobject_klass->dispose = gst_cea708dec_dispose;
 
   /* Pads */
   gst_element_class_add_pad_template (gstelement_klass,
@@ -269,15 +224,7 @@ gst_cea708dec_class_init (GstCea708DecClass * klass)
       "cea708dec",
       "Decoder", "closed caption decoding element",
       "CableLabs RUIH-RI Team <ruihri@cablelabs.com>");
-#ifndef STANDALONE_ELEMENT
   GST_DEBUG_CATEGORY_INIT (gst_cea708dec_debug, "cea708dec", 0, "CC Decoder");
-#endif
-#ifdef DEBUG_ELEMENT_SIZE
-  g_message ("%s %d = sizeof(_GstCea708Dec)\n", __func__,
-      sizeof (struct _GstCea708Dec));
-  g_message ("%s %d = sizeof(cea708Window)\n", __func__, sizeof (cea708Window));
-  g_message ("%s %d = sizeof(cea708char)\n", __func__, sizeof (cea708char));
-#endif
 }
 
 static void
@@ -286,20 +233,15 @@ gst_cea708dec_dispose (GObject * object)
   guint i;
   GstCea708Dec *decoder = GST_CEA708DEC (object);
 
-  // Free memory allocated in gst_cea708dec_init()
+  /* Free memory allocated in gst_cea708dec_init() */
   for (i = 0; i < MAX_708_WINDOWS; i++) {
-    if (decoder->cc_windows[i]) {
-      g_free (decoder->cc_windows[i]);
-      decoder->cc_windows[i] = NULL;
-    }
+    g_free (decoder->cc_windows[i]);
+    decoder->cc_windows[i] = NULL;
   }
 
-  if (decoder->text_list) {
-    g_slist_free_full (decoder->text_list, g_free);
-    decoder->text_list = NULL;
-  }
-
-  GST_INFO_OBJECT (decoder, "complete");
+  g_slist_free_full (decoder->text_list, g_free);
+  decoder->text_list = NULL;
+  GST_DEBUG_OBJECT (decoder, "complete");
   G_OBJECT_CLASS (gst_cea708dec_parent_class)->dispose (object);
 }
 
@@ -308,28 +250,23 @@ gst_cea708dec_init (GstCea708Dec * decoder)
 {
   guint i;
   GST_DEBUG_OBJECT (decoder, "called");
-  decoder->text_list = NULL;
   gst_segment_init (&decoder->segment, GST_FORMAT_UNDEFINED);
 
-  // Add sink pad
+  /* Add sink pad */
   decoder->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
   gst_pad_set_event_function (decoder->sinkpad, gst_cea708dec_sink_events);
   gst_pad_set_chain_function (decoder->sinkpad, gst_cea708dec_chain);
   gst_element_add_pad (GST_ELEMENT (decoder), decoder->sinkpad);
-  GST_INFO_OBJECT (decoder, "sink pad added to decoder");
-  decoder->srcpad = NULL;
+  GST_DEBUG_OBJECT (decoder, "sink pad added to decoder");
 
-  // Initialize 708 variables
+  /* Initialize 708 variables */
   for (i = 0; i < MAX_708_WINDOWS; i++) {
     decoder->cc_windows[i] = g_malloc (sizeof (cea708Window));
     gst_cea708dec_init_window (decoder, i);
   }
 
-  decoder->current_window = 0;
   decoder->desired_service = -1;
   decoder->previous_desired_service = -1;
-  decoder->output_ignore = 0;
-  decoder->current_time = 0;
 }
 
 static gboolean
@@ -340,7 +277,7 @@ gst_cea708dec_sink_events (GstPad * pad, GstObject * parent, GstEvent * event)
 
   switch (GST_EVENT_TYPE (event)) {
     case GST_EVENT_SEGMENT:
-      GST_INFO_OBJECT (decoder, "Received SEGMENT event on %s pad",
+      GST_DEBUG_OBJECT (decoder, "Received SEGMENT event on %s pad",
           gst_pad_get_name (pad));
       gst_event_copy_segment (event, &decoder->segment);
       break;
@@ -366,13 +303,13 @@ gst_cea708dec_send_new_segment (GstCea708Dec * decoder)
     decoder->segment.format = GST_FORMAT_BYTES;
   }
 
-  GST_INFO_OBJECT (decoder, "Sending segment %" GST_SEGMENT_FORMAT,
+  GST_DEBUG_OBJECT (decoder, "Sending segment %" GST_SEGMENT_FORMAT,
       &decoder->segment);
   event = gst_event_new_segment (&decoder->segment);
   return gst_pad_push_event (decoder->srcpad, event);
 }
 
-static gboolean
+static void
 gst_cea708dec_add_text_srcpad (GstCea708Dec * decoder)
 {
   gchar *start_id = NULL;
@@ -384,9 +321,9 @@ gst_cea708dec_add_text_srcpad (GstCea708Dec * decoder)
       GST_ELEMENT (decoder), "src");
   gst_pad_push_event (decoder->srcpad, gst_event_new_stream_start (start_id));
   g_free (start_id);
+  gst_cea708dec_send_new_segment (decoder);
   gst_element_add_pad (GST_ELEMENT (decoder), decoder->srcpad);
   gst_element_no_more_pads (GST_ELEMENT (decoder));
-  return gst_cea708dec_send_new_segment (decoder);
 }
 
 static void
@@ -411,19 +348,19 @@ gst_cea708dec_scroll_window_up (GstCea708Dec * decoder, guint window_id)
   cea708Window *window = decoder->cc_windows[window_id];
   guint row, col;
 
-  // This function should be called to scroll the window up if bottom to
-  // top scrolling is enabled and a carraige-return is encountered, or
-  // word-wrapping
-  GST_DEBUG_OBJECT (decoder, "called for window: %d", window_id);
+  /* This function should be called to scroll the window up if bottom to
+   * top scrolling is enabled and a carraige-return is encountered, or
+   * word-wrapping */
+  GST_LOG_OBJECT (decoder, "called for window: %d", window_id);
 
-  // start at row 1 to copy into row 0 (scrolling up)
+  /* start at row 1 to copy into row 0 (scrolling up) */
   for (row = 1; row < WINDOW_MAX_ROWS; row++) {
     for (col = 0; col < WINDOW_MAX_COLS; col++) {
       window->text[row - 1][col] = window->text[row][col];
     }
   }
 
-  // Clear the bottom row:
+  /* Clear the bottom row: */
   row = WINDOW_MAX_ROWS - 1;
   for (col = 0; col < WINDOW_MAX_COLS; col++) {
     window->text[row][col].c = ' ';
@@ -475,15 +412,15 @@ gst_cea708dec_init_window (GstCea708Dec * decoder, guint window_id)
   window->pen_attributes.underline = FALSE;
   window->pen_attributes.edge_type = EDGE_TYPE_NONE;
 
-  // Init pen position
+  /* Init pen position */
   window->pen_row = 0;
   window->pen_col = 0;
 
-  // Initialize text array to all spaces. When sending window text, only
-  // send if there are non-blank rows
+  /* Initialize text array to all spaces. When sending window text, only
+   * send if there are non-blank rows */
   gst_cea708dec_clear_window_text (decoder, window_id);
 
-  // window attributes
+  /* window attributes */
   window->justify_mode = JUSTIFY_LEFT;
   window->print_direction = PRINT_DIR_LEFT_TO_RIGHT;
   window->scroll_direction = SCROLL_DIR_BOTTOM_TO_TOP;
@@ -518,7 +455,7 @@ gst_cea708dec_set_pen_style (GstCea708Dec * decoder, guint8 pen_style_id)
   window->pen_color.bg_opacity = SOLID;
   window->pen_color.edge_color = COLOR_BLACK;
 
-  // CEA-708 predefined pen style ids
+  /* CEA-708 predefined pen style ids */
   switch (pen_style_id) {
     default:
     case PEN_STYLE_DEFAULT:
@@ -558,7 +495,7 @@ gst_cea708dec_set_window_style (GstCea708Dec * decoder, guint8 style_id)
 {
   cea708Window *window = decoder->cc_windows[decoder->current_window];
 
-  // set the 'normal' styles first, then deviate in special cases below...
+  /* set the 'normal' styles first, then deviate in special cases below... */
   window->justify_mode = JUSTIFY_LEFT;
   window->print_direction = PRINT_DIR_LEFT_TO_RIGHT;
   window->scroll_direction = SCROLL_DIR_BOTTOM_TO_TOP;
@@ -569,7 +506,7 @@ gst_cea708dec_set_window_style (GstCea708Dec * decoder, guint8 style_id)
   window->fill_color = COLOR_BLACK;
   window->fill_opacity = SOLID;
 
-  // CEA-708 predefined window style ids
+  /* CEA-708 predefined window style ids */
   switch (style_id) {
     default:
     case WIN_STYLE_NORMAL:
@@ -604,7 +541,7 @@ gst_cea708dec_set_window_style (GstCea708Dec * decoder, guint8 style_id)
   }
 }
 
-// For debug, print name of 708 command
+/* For debug, print name of 708 command */
 static void
 gst_cea708dec_print_command_name (GstCea708Dec * decoder, guint8 c)
 {
@@ -624,7 +561,7 @@ gst_cea708dec_print_command_name (GstCea708Dec * decoder, guint8 c)
     case CC_COMMAND_CW5:
     case CC_COMMAND_CW6:
     case CC_COMMAND_CW7:
-      // Set current window, no parameters
+      /* Set current window, no parameters */
       g_snprintf (buffer, sizeof (buffer), "Set current window %d", c & 0x3);
       command = buffer;
       break;
@@ -693,10 +630,10 @@ gst_cea708dec_print_command_name (GstCea708Dec * decoder, guint8 c)
       if ((c > 0x80) && (c < 0x9F))
         command = (const gchar *) "Unknown";
       break;
-  }                             // switch
+  }                             /* switch */
 
   if (NULL != command) {
-    GST_DEBUG_OBJECT (decoder, "Process 708 command (%02X): %s", c, command);
+    GST_LOG_OBJECT (decoder, "Process 708 command (%02X): %s", c, command);
   }
 }
 
@@ -708,31 +645,29 @@ get_cea708dec_bufcat (gpointer data, gpointer user_data)
   g_free (data);
 }
 
-static void
+static GstFlowReturn
 gst_cea708dec_send_text (GstObject * decoder, GSList ** text_list, gint length,
     GstPad * pad)
 {
+  GstFlowReturn ret_val = GST_FLOW_ERROR;
   GstBuffer *outbuf = NULL;
   GstMapInfo map = { 0 };
 
   if (0 < length) {
     outbuf = gst_buffer_new_and_alloc (length);
-
-    if (outbuf) {
-      gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
-      map.data[0] = 0;
-      g_slist_foreach (*text_list, get_cea708dec_bufcat, &map);
-      GST_INFO_OBJECT (decoder, "sent \n%s\n", map.data);
-      gst_buffer_unmap (outbuf, &map);
-      gst_pad_push (pad, outbuf);
-      g_slist_free (*text_list);
-      // data freed in slist loop!
-      //g_slist_free_full (*text_list, g_free);
-      *text_list = NULL;
-    } else {
-      GST_ERROR_OBJECT (decoder, "ERROR allocating %d", length);
-    }
+    gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
+    map.data[0] = 0;
+    g_slist_foreach (*text_list, get_cea708dec_bufcat, &map);
+    GST_DEBUG_OBJECT (decoder, "sent \n%s\n", map.data);
+    gst_buffer_unmap (outbuf, &map);
+    ret_val = gst_pad_push (pad, outbuf);
+    g_slist_free (*text_list);
+    /* data freed in slist loop!
+     *g_slist_free_full (*text_list, g_free); */
+    *text_list = NULL;
   }
+
+  return ret_val;
 }
 
 static gint
@@ -740,18 +675,14 @@ gst_cea708dec_text_list_add (GstObject * decoder, GSList ** text_list,
     gint len, const gchar * format, ...)
 {
   va_list args;
-  gchar *str = NULL;
+  gchar *str;
 
   va_start (args, format);
 
-  if (NULL != (str = g_malloc0 (len))) {
-    len = g_vsnprintf (str, len, format, args);
-    *text_list = g_slist_append (*text_list, str);
-    GST_LOG_OBJECT (decoder, "added %p str[%d]: %s", str, len, str);
-  } else {
-    len = 0;
-    GST_ERROR_OBJECT (decoder, "failure to add the text!?");
-  }
+  str = g_malloc0 (len);
+  len = g_vsnprintf (str, len, format, args);
+  *text_list = g_slist_append (*text_list, str);
+  GST_LOG_OBJECT (decoder, "added %p str[%d]: %s", str, len, str);
 
   va_end (args);
   return len;
@@ -765,8 +696,8 @@ gst_cea708dec_timestamp_to_string (guint64 pts, gchar * buffer, size_t size)
   guint secs = 0;
   guint msec = 0;
 
-  // The TS is in units of 1/90000 of a second....
-  // Convert to hours, minutes, seconds & msec
+  /* The TS is in units of 1/90000 of a second....
+   * Convert to hours, minutes, seconds & msec */
   hours = pts / (90000 * 60 * 60);
   pts %= (90000 * 60 * 60);
   mins = pts / (90000 * 60);
@@ -783,13 +714,13 @@ gst_cea708dec_show_window (GstCea708Dec * decoder, guint window_id)
 {
   cea708Window *window = decoder->cc_windows[decoder->current_window];
   guint16 row, col;
-  gboolean display = FALSE;     // = TRUE when text lines should be written
+  gboolean display = FALSE;     /* = TRUE when text lines should be written */
   gchar line_buffer[LINEBUFFER_SIZE];
   gchar start_time[100];
   gchar end_time[100];
   guint16 i;
-  guint16 right_index;          // within a single line of window text, the
-  // index of the rightmost non-blank character
+  guint16 right_index;          /* within a single line of window text, the
+                                 * index of the rightmost non-blank character */
   guint32 percent;
   guint16 index;
   guint len = 0;
@@ -804,10 +735,10 @@ gst_cea708dec_show_window (GstCea708Dec * decoder, guint window_id)
   if (!window->visible) {
     return;
   }
-  // This function called when a window loses visibility, typically
-  // - The window is being deleted
-  // - visbility was toggled to false
-  // Create a text cue from the text in the text array
+  /* This function called when a window loses visibility, typically
+   * - The window is being deleted
+   * - visbility was toggled to false
+   * Create a text cue from the text in the text array */
 
   if (window->start_time == 0) {
     GST_LOG_OBJECT (decoder, "window start_time was 0");
@@ -817,20 +748,20 @@ gst_cea708dec_show_window (GstCea708Dec * decoder, guint window_id)
   for (row = 0; row < window->row_count; row++) {
     for (col = 0; col < window->column_count; col++) {
       if (window->text[row][col].c != ' ') {
-        // If there is a non-blank line, then display from there
+        /* If there is a non-blank line, then display from there */
         display = TRUE;
         bytes++;
       }
     }
   }
 
-  // Each line of the window that has text will be a separate WebVTT text cue.
+  /* Each line of the window that has text will be a separate WebVTT text cue. */
   if (display) {
     guint64 length = 0;
     gst_cea708dec_timestamp_to_string (window->start_time, start_time,
         sizeof (start_time));
-    // Guess at the duration (since we're converting real-time CC data into
-    // static start and end times and we only know the start...
+    /* Guess at the duration (since we're converting real-time CC data into
+     * static start and end times and we only know the start... */
     length = MAX ((bytes * TS_MSEC (65)), TS_SECS (1));
     gst_cea708dec_timestamp_to_string (window->start_time + length, end_time,
         sizeof (end_time));
@@ -838,14 +769,14 @@ gst_cea708dec_show_window (GstCea708Dec * decoder, guint window_id)
     for (row = 0; row < window->row_count; row++) {
       for (col = 0; col < window->column_count; col++) {
         if (window->text[row][col].c != ' ') {
-          // This line is non-blank
+          /* This line is non-blank
 
-          // Convert column to percent for WebVTT using a number for width
-          // based on the maximum size of a 708 screen
+           * Convert column to percent for WebVTT using a number for width
+           * based on the maximum size of a 708 screen */
           percent = (window->h_offset + col) * 100;
           percent /= SCREEN_WIDTH_708;
 
-          // Determine alignment
+          /* Determine alignment */
           switch (window->text[row][col].justify_mode) {
             case JUSTIFY_LEFT:
               align = "align:start";
@@ -860,7 +791,7 @@ gst_cea708dec_show_window (GstCea708Dec * decoder, guint window_id)
               break;
           }
 
-          // Determine font name
+          /* Determine font name */
           switch (window->text[row][col].pen_attributes.font_style) {
             case FONT_STYLE_MONO_SERIF:
               font = "mono_serif";
@@ -896,26 +827,26 @@ gst_cea708dec_show_window (GstCea708Dec * decoder, guint window_id)
               break;
           }
 
-          // Look up color name for foreground/background
-          // TODO: add opacity
+          /* Look up color name for foreground/background
+           * TODO: add opacity */
           foreground_color =
               color_names[(window->text[row][col].pen_color.fg_color) & 0x3F];
           background_color =
               color_names[(window->text[row][col].pen_color.bg_color) & 0x3F];
 
-          // Write the time, position, color, etc
+          /* Write the time, position, color, etc */
           len += gst_cea708dec_text_list_add_webvtt (decoder, start_time,
               end_time, align,
 #ifdef WEBVTT_LINE_PERCENT
-              // Vertical position (line) as percent
+              /* Vertical position (line) as percent */
               (row + window->v_offset) * 100 / SCREEN_HEIGHT_708,
 #else
-              // Add 1 so the line numbers are 1-based
+              /* Add 1 so the line numbers are 1-based */
               row + window->v_offset + 1,
 #endif
               percent);
 
-          // Find the rightmost non-blank character on this line:
+          /* Find the rightmost non-blank character on this line: */
           for (i = right_index = WINDOW_MAX_COLS - 1; i >= col; i--) {
             if (window->text[row][i].c != ' ') {
               right_index = i;
@@ -923,8 +854,8 @@ gst_cea708dec_show_window (GstCea708Dec * decoder, guint window_id)
             }
           }
 
-          // Copy all of the characters in this row, from the current position
-          // to the right edge
+          /* Copy all of the characters in this row, from the current position
+           * to the right edge */
           underline = FALSE;
           italics = FALSE;
 
@@ -933,32 +864,32 @@ gst_cea708dec_show_window (GstCea708Dec * decoder, guint window_id)
             GST_LOG_OBJECT (decoder, "Adding row=%d i=%d c=%c %d", row,
                 i, window->text[row][i].c, window->text[row][i].c);
 
-            // Check for transitions to/from underline:
+            /* Check for transitions to/from underline: */
             if ((window->text[row][i].pen_attributes.underline) && (!underline)) {
-              // beginning of underline mode
+              /* beginning of underline mode */
               line_buffer[index++] = '<';
               line_buffer[index++] = 'u';
               line_buffer[index++] = '>';
               underline = TRUE;
             } else if ((!window->text[row][i].pen_attributes.underline)
                 && (underline)) {
-              // underline mode ends
+              /* underline mode ends */
               line_buffer[index++] = '<';
               line_buffer[index++] = '/';
               line_buffer[index++] = 'u';
               line_buffer[index++] = '>';
               underline = FALSE;
             }
-            // Check for transitions to/from italics:
+            /* Check for transitions to/from italics: */
             if ((window->text[row][i].pen_attributes.italics) && (!italics)) {
-              // beginning of italics mode
+              /* beginning of italics mode */
               line_buffer[index++] = '<';
               line_buffer[index++] = 'i';
               line_buffer[index++] = '>';
               italics = TRUE;
             } else if ((!window->text[row][i].pen_attributes.italics)
                 && (italics)) {
-              // italics mode ends
+              /* italics mode ends */
               line_buffer[index++] = '<';
               line_buffer[index++] = '/';
               line_buffer[index++] = 'i';
@@ -971,7 +902,7 @@ gst_cea708dec_show_window (GstCea708Dec * decoder, guint window_id)
           }
 
           if (underline) {
-            // underline mode ends on each line end
+            /* underline mode ends on each line end */
             line_buffer[index++] = '<';
             line_buffer[index++] = '/';
             line_buffer[index++] = 'u';
@@ -979,7 +910,7 @@ gst_cea708dec_show_window (GstCea708Dec * decoder, guint window_id)
           }
 
           if (italics) {
-            // italics mode ends on each line end
+            /* italics mode ends on each line end */
             line_buffer[index++] = '<';
             line_buffer[index++] = '/';
             line_buffer[index++] = 'i';
@@ -1003,12 +934,12 @@ gst_cea708dec_show_window (GstCea708Dec * decoder, guint window_id)
   if (len == 0) {
     GST_LOG_OBJECT (decoder, "window %d had no text", window_id);
   } else {
-    // send text to output pad
+    /* send text to output pad */
     gst_cea708dec_send_text (GST_OBJECT (decoder), &decoder->text_list, len,
         decoder->srcpad);
   }
 
-  // this window has been shown, reset it's start time...
+  /* this window has been shown, reset it's start time... */
   window->start_time = 0;
 }
 
@@ -1019,8 +950,8 @@ gst_cea708dec_window_add_char (GstCea708Dec * decoder, guint8 c)
   guint16 pen_row;
   guint16 pen_col;
 
-  // Add one character to the current window, using current pen location.
-  // Wrap pen location if necessary
+  /* Add one character to the current window, using current pen location.
+   * Wrap pen location if necessary */
   if (c == 0)
     return;
 
@@ -1035,7 +966,7 @@ gst_cea708dec_window_add_char (GstCea708Dec * decoder, guint8 c)
       gst_cea708dec_scroll_window_up (decoder, decoder->current_window);
     }
   }
-  // Make sure row/col limits are not too large
+  /* Make sure row/col limits are not too large */
   if (window->row_count > WINDOW_MAX_ROWS) {
     window->row_count = WINDOW_MAX_ROWS;
   }
@@ -1053,7 +984,7 @@ gst_cea708dec_window_add_char (GstCea708Dec * decoder, guint8 c)
       gst_cea708dec_scroll_window_up (decoder, decoder->current_window);
     }
   }
-  // Wrap row position if too large
+  /* Wrap row position if too large */
   if (window->pen_row >= window->row_count) {
     window->pen_row = 0;
   }
@@ -1062,13 +993,13 @@ gst_cea708dec_window_add_char (GstCea708Dec * decoder, guint8 c)
     pen_row = window->pen_row;
     pen_col = window->pen_col;
 
-    GST_DEBUG_OBJECT (decoder,
+    GST_LOG_OBJECT (decoder,
         "[text x=%d y=%d fgcolor=%d win=%d vis=%d] %c %X", pen_col, pen_row,
         window->pen_color.fg_color, decoder->current_window,
         window->visible, c, c);
 
-    // Each cell in the window should get the current pen color and
-    // attributes as it is written
+    /* Each cell in the window should get the current pen color and
+     * attributes as it is written */
     window->text[pen_row][pen_col].c = c;
     window->text[pen_row][pen_col].justify_mode = window->justify_mode;
     window->text[pen_row][pen_col].pen_color = window->pen_color;
@@ -1094,7 +1025,7 @@ gst_cea708dec_window_add_char (GstCea708Dec * decoder, guint8 c)
           window->pen_row--;
         }
         break;
-    }                           // switch (print_direction)
+    }                           /* switch (print_direction) */
   }
 }
 
@@ -1104,9 +1035,9 @@ gst_cea708dec_set_pen_attributes (GstCea708Dec * decoder, guint8 * dtvcc_buffer,
 {
   cea708Window *window = decoder->cc_windows[decoder->current_window];
 
-  // format
-  //tt3 tt2 tt1 tt0 o1 o0 s1 s0
-  //i u et2 et1 et0 fs2 fs1 fs0
+  /* format
+     tt3 tt2 tt1 tt0 o1 o0 s1 s0
+     i u et2 et1 et0 fs2 fs1 fs0 */
   window->pen_attributes.pen_size = dtvcc_buffer[index] & 0x3;
   window->pen_attributes.font_style = dtvcc_buffer[index + 1] & 0x3;
   window->pen_attributes.text_tag = (dtvcc_buffer[index] & 0xF0) >> 4;
@@ -1117,12 +1048,12 @@ gst_cea708dec_set_pen_attributes (GstCea708Dec * decoder, guint8 * dtvcc_buffer,
       ((dtvcc_buffer[index + 1] & 0x40) >> 6) ? TRUE : FALSE;
   window->pen_attributes.edge_type = (dtvcc_buffer[index + 1] & 0x38) >> 3;
 
-  GST_DEBUG_OBJECT (decoder, "pen_size=%d font=%d text_tag=%d offset=%d",
+  GST_LOG_OBJECT (decoder, "pen_size=%d font=%d text_tag=%d offset=%d",
       window->pen_attributes.pen_size,
       window->pen_attributes.font_style,
       window->pen_attributes.text_tag, window->pen_attributes.offset);
 
-  GST_DEBUG_OBJECT (decoder, "italics=%d underline=%d edge_type=%d",
+  GST_LOG_OBJECT (decoder, "italics=%d underline=%d edge_type=%d",
       window->pen_attributes.italics,
       window->pen_attributes.underline, window->pen_attributes.edge_type);
 }
@@ -1133,17 +1064,17 @@ gst_cea708dec_set_pen_color (GstCea708Dec * decoder, guint8 * dtvcc_buffer,
 {
   cea708Window *window = decoder->cc_windows[decoder->current_window];
 
-  // format
-  // fo1 fo0 fr1 fr0 fg1 fg0 fb1 fb0
-  // bo1 bo0 br1 br0 bg1 bg0 bb1 bb0
-  // 0 0 er1 er0 eg1 eg0 eb1 eb0
+  /* format
+     fo1 fo0 fr1 fr0 fg1 fg0 fb1 fb0
+     bo1 bo0 br1 br0 bg1 bg0 bb1 bb0
+     0 0 er1 er0 eg1 eg0 eb1 eb0 */
   window->pen_color.fg_color = dtvcc_buffer[index] & 0x3F;
   window->pen_color.fg_opacity = (dtvcc_buffer[index] & 0xC0) >> 6;
   window->pen_color.bg_color = dtvcc_buffer[index + 1] & 0x3F;
   window->pen_color.bg_opacity = (dtvcc_buffer[index + 1] & 0xC0) >> 6;
   window->pen_color.edge_color = dtvcc_buffer[index + 2] & 0x3F;
 
-  GST_DEBUG_OBJECT (decoder,
+  GST_LOG_OBJECT (decoder,
       "pen_color fg=0x%x fg_op=0x%x bg=0x%x bg_op=0x%x edge=0x%x",
       window->pen_color.fg_color,
       window->pen_color.fg_opacity,
@@ -1157,11 +1088,11 @@ gst_cea708dec_set_window_attributes (GstCea708Dec * decoder,
 {
   cea708Window *window = decoder->cc_windows[decoder->current_window];
 
-  // format
-  // fo1 fo0 fr1 fr0 fg1 fg0 fb1 fb0
-  // bt1 bt0 br1 br0 bg1 bg0 bb1 bb0
-  // bt2 ww  pd1 pd0 sd1 sd0 j1  j0
-  // es3 es2 es1 es0 ed1 ed0 de1 de0
+  /* format
+     fo1 fo0 fr1 fr0 fg1 fg0 fb1 fb0
+     bt1 bt0 br1 br0 bg1 bg0 bb1 bb0
+     bt2 ww  pd1 pd0 sd1 sd0 j1  j0
+     es3 es2 es1 es0 ed1 ed0 de1 de0 */
   window->fill_color = dtvcc_buffer[index] & 0x3F;
   window->fill_opacity = (dtvcc_buffer[index] & 0xC0) >> 6;
   window->border_color = dtvcc_buffer[index + 1] & 0x3F;
@@ -1175,10 +1106,10 @@ gst_cea708dec_set_window_attributes (GstCea708Dec * decoder,
   window->effect_direction = (dtvcc_buffer[index + 3] & 0xC);
   window->effect_speed = (dtvcc_buffer[index + 3] & 0xF0) >> 4;
 
-  GST_DEBUG_OBJECT (decoder, "Print direction = %d", window->print_direction);
+  GST_LOG_OBJECT (decoder, "Print direction = %d", window->print_direction);
 }
 
-// Define window - window size, window style, pen style, anchor position, etc
+/* Define window - window size, window style, pen style, anchor position, etc */
 static void
 gst_cea708dec_define_window (GstCea708Dec * decoder, guint8 * dtvcc_buffer,
     int index)
@@ -1199,51 +1130,51 @@ gst_cea708dec_define_window (GstCea708Dec * decoder, guint8 * dtvcc_buffer,
   guint v_anchor = 0;
   guint h_anchor = 0;
 
-  GST_DEBUG_OBJECT (decoder, "current_window=%d", decoder->current_window);
-  GST_DEBUG_OBJECT (decoder, "dtvcc_buffer %02x %02x %02x %02x %02x %02x",
+  GST_LOG_OBJECT (decoder, "current_window=%d", decoder->current_window);
+  GST_LOG_OBJECT (decoder, "dtvcc_buffer %02x %02x %02x %02x %02x %02x",
       dtvcc_buffer[index + 0], dtvcc_buffer[index + 1],
       dtvcc_buffer[index + 2], dtvcc_buffer[index + 3],
       dtvcc_buffer[index + 4], dtvcc_buffer[index + 5]);
 
-  // Initialize window structure
+  /* Initialize window structure */
   if (NULL != window) {
     if (window->deleted) {
-      // Spec says on window create (but not re-definition) the pen position
-      // must be reset to 0
-      // TODO: also set all text positions to the fill color
+      /* Spec says on window create (but not re-definition) the pen position
+       * must be reset to 0
+       * TODO: also set all text positions to the fill color */
       window->deleted = FALSE;
       window->pen_row = 0;
       window->pen_col = 0;
     }
-    // format of parameters:
-    //0 0 v rl cl p2 p1 p0
-    //rp av7 av6 av5 av4 av3 av1 av0
-    //ah7 ah6 ah5 ah4 ah3 ah2 ah1 ah0
-    //ap3 ap2 ap1 ap0 rc3 rc2 rc1 rc0
-    //0 0 cc5 cc4 cc3 cc2 cc1 cc0
-    //0 0 ws2 ws1 ws0 ps2 ps1 ps0
-
-    // parameter byte 0
+    /* format of parameters:
+       0 0 v rl cl p2 p1 p0
+       rp av7 av6 av5 av4 av3 av1 av0
+       ah7 ah6 ah5 ah4 ah3 ah2 ah1 ah0
+       ap3 ap2 ap1 ap0 rc3 rc2 rc1 rc0
+       0 0 cc5 cc4 cc3 cc2 cc1 cc0
+       0 0 ws2 ws1 ws0 ps2 ps1 ps0 */
+
+    /* parameter byte 0 */
     priority = dtvcc_buffer[index] & 0x7;
     column_lock = (dtvcc_buffer[index] & 0x8) ? TRUE : FALSE;
     row_lock = (dtvcc_buffer[index] & 0x10) ? TRUE : FALSE;
     visible = (dtvcc_buffer[index] & 0x20) ? TRUE : FALSE;
 
-    // parameter byte 1
+    /* parameter byte 1 */
     relative_position = (dtvcc_buffer[index + 1] & 0x80) ? TRUE : FALSE;
     anchor_vertical = dtvcc_buffer[index + 1] & 0x7F;
 
-    // parameter byte 2
+    /* parameter byte 2 */
     anchor_horizontal = dtvcc_buffer[index + 2];
 
-    // parameter byte 3
+    /* parameter byte 3 */
     anchor_point = (dtvcc_buffer[index + 3] & 0xF0) >> 4;
     row_count = (dtvcc_buffer[index + 3] & 0xF) + 1;
 
-    // parameter byte 4
+    /* parameter byte 4 */
     column_count = (dtvcc_buffer[index + 4] & 0x3F) + 1;
 
-    // parameter byte 5
+    /* parameter byte 5 */
     style_id = (dtvcc_buffer[index + 5] & 0x38) >> 3;
     pen_style_id = dtvcc_buffer[index + 5] & 0x3;
 
@@ -1251,7 +1182,7 @@ gst_cea708dec_define_window (GstCea708Dec * decoder, guint8 * dtvcc_buffer,
     window->screen_horizontal = anchor_horizontal;
 
     if (relative_position == FALSE) {
-      // If position is in absolute coords, convert to percent
+      /* If position is in absolute coords, convert to percent */
       window->screen_vertical /= SCREEN_HEIGHT;
       window->screen_horizontal /= SCREEN_WIDTH;
       window->screen_vertical *= 100;
@@ -1261,12 +1192,12 @@ gst_cea708dec_define_window (GstCea708Dec * decoder, guint8 * dtvcc_buffer,
     window->v_offset = 0;
     window->h_offset = 0;
 
-    // Calculate the position of the anchor point of the window in char units
-    // within a hypothetical 708 screen
+    /* Calculate the position of the anchor point of the window in char units
+     * within a hypothetical 708 screen */
     v_anchor = window->screen_vertical * SCREEN_HEIGHT_708 / 100;
     h_anchor = window->screen_horizontal * SCREEN_WIDTH_708 / 100;
 
-    // Adjust position based on anchor point
+    /* Adjust position based on anchor point */
     switch (anchor_point) {
       case ANCHOR_PT_TOP_LEFT:
         window->v_offset = v_anchor;
@@ -1337,20 +1268,20 @@ gst_cea708dec_define_window (GstCea708Dec * decoder, guint8 * dtvcc_buffer,
     gst_cea708dec_set_pen_style (decoder, window->pen_style_id);
   }
 
-  GST_DEBUG_OBJECT (decoder,
+  GST_LOG_OBJECT (decoder,
       "priority=%d anchor=%d relative_pos=%d anchor_v=%d anchor_h=%d",
       window->priority,
       window->anchor_point,
       window->relative_position,
       window->anchor_vertical, window->anchor_horizontal);
 
-  GST_DEBUG_OBJECT (decoder,
+  GST_LOG_OBJECT (decoder,
       "row_count=%d col_count=%d row_lock=%d col_lock=%d visible=%d",
       window->row_count,
       window->column_count,
       window->row_lock, window->column_lock, window->visible);
 
-  GST_DEBUG_OBJECT (decoder,
+  GST_LOG_OBJECT (decoder,
       "style_id=%d pen_style_id=%d screenH=%f screenV=%f v_offset=%d "
       "h_offset=%d v_anchor=%d h_anchor=%d",
       window->style_id,
@@ -1367,11 +1298,11 @@ gst_cea708dec_for_each_window (GstCea708Dec * decoder, guint8 window_list,
 {
   guint i;
 
-  GST_DEBUG_OBJECT (decoder, "window_list: %02x", window_list);
+  GST_LOG_OBJECT (decoder, "window_list: %02x", window_list);
 
   for (i = 0; i < MAX_708_WINDOWS; i++) {
     if (WINDOW_IN_LIST_IS_ACTIVE (window_list)) {
-      GST_DEBUG_OBJECT (decoder, "%s[%d]:%d %s v_offset=%d h_offset=%d",
+      GST_LOG_OBJECT (decoder, "%s[%d]:%d %s v_offset=%d h_offset=%d",
           log_message, i, WINDOW_IN_LIST_IS_ACTIVE (window_list),
           (decoder->cc_windows[i]->visible) ? "visible" : "hidden",
           decoder->cc_windows[i]->v_offset, decoder->cc_windows[i]->h_offset);
@@ -1408,28 +1339,26 @@ gst_cea708dec_process_dtvcc_byte (GstCea708Dec * decoder, guint8 * dtvcc_buffer,
 {
   cea708Window *window = decoder->cc_windows[decoder->current_window];
   guint8 c = dtvcc_buffer[index];
-  guint8 window_list = dtvcc_buffer[index + 1]; // always the first arg (if any)
+  guint8 window_list = dtvcc_buffer[index + 1]; /* always the first arg (if any) */
 
   if (decoder->output_ignore) {
-    // Ignore characters/parameters after a command.
+    /* Ignore characters/parameters after a command. */
     GST_LOG_OBJECT (decoder, "[%d] ignore %X", decoder->output_ignore, c);
     decoder->output_ignore--;
     return;
   }
 
   if (c == 0)
-    return;                     // neither a command, nor text
+    return;                     /* neither a command, nor text */
 
-  // Process command codes and text:
+  /* Process command codes and text: */
   gst_cea708dec_print_command_name (decoder, c);
   switch (c) {
-      //----- End of text ----------------------------------------------------
-    case CC_COMMAND_ETX:
+    case CC_COMMAND_ETX:       /* End of text */
       gst_cea708dec_show_window (decoder, decoder->current_window);
       return;
 
-      //----- Set current window ---------------------------------------------
-    case CC_COMMAND_CW0:
+    case CC_COMMAND_CW0:       /* Set current window */
     case CC_COMMAND_CW1:
     case CC_COMMAND_CW2:
     case CC_COMMAND_CW3:
@@ -1438,110 +1367,98 @@ gst_cea708dec_process_dtvcc_byte (GstCea708Dec * decoder, guint8 * dtvcc_buffer,
     case CC_COMMAND_CW6:
     case CC_COMMAND_CW7:
       decoder->current_window = c & 0x03;
-      GST_DEBUG_OBJECT (decoder, "Current window=%d", decoder->current_window);
+      GST_LOG_OBJECT (decoder, "Current window=%d", decoder->current_window);
       return;
 
-      //----- Clear windows ---------------------------------------------------
-    case CC_COMMAND_CLW:
-      decoder->output_ignore = 1;       // 1 byte parameter = windowmap
+    case CC_COMMAND_CLW:       /* Clear windows */
+      decoder->output_ignore = 1;       /* 1 byte parameter = windowmap */
 
-      // Clear window data
+      /* Clear window data */
       gst_cea708dec_for_each_window (decoder, window_list, NO_CHANGE,
           "clear_window", gst_cea708dec_clear_window_text);
       return;
 
-      //----- Display windows -------------------------------------------------
-    case CC_COMMAND_DSW:
-      decoder->output_ignore = 1;       // 1 byte parameter = windowmap
+    case CC_COMMAND_DSW:       /* Display windows */
+      decoder->output_ignore = 1;       /* 1 byte parameter = windowmap */
 
-      // Show window
+      /* Show window */
       gst_cea708dec_for_each_window (decoder, window_list, NO_CHANGE,
           "display_window", gst_cea708dec_show_window);
       return;
 
-      //----- Hide windows ---------------------------------------------------
-    case CC_COMMAND_HDW:
-      decoder->output_ignore = 1;       // 1 byte parameter = windowmap
+    case CC_COMMAND_HDW:       /* Hide windows */
+      decoder->output_ignore = 1;       /* 1 byte parameter = windowmap */
 
-      // Hide window
+      /* Hide window */
       gst_cea708dec_for_each_window (decoder, window_list, SWITCH_TO_HIDE,
           "hide_window", NULL);
       return;
 
-      //----- Toggle windows ---------------------------------------------------
-    case CC_COMMAND_TGW:
-      decoder->output_ignore = 1;       // 1 byte parameter = windowmap
+    case CC_COMMAND_TGW:       /* Toggle windows */
+      decoder->output_ignore = 1;       /* 1 byte parameter = windowmap */
 
-      // Toggle windows - hide displayed windows, display hidden windows
+      /* Toggle windows - hide displayed windows, display hidden windows */
       gst_cea708dec_for_each_window (decoder, window_list, TOGGLE,
           "toggle_window", gst_cea708dec_show_window);
       return;
 
-      //----- Delete windows ---------------------------------------------------
-    case CC_COMMAND_DLW:
-      decoder->output_ignore = 1;       // 1 byte parameter = windowmap
+    case CC_COMMAND_DLW:       /* Delete windows */
+      decoder->output_ignore = 1;       /* 1 byte parameter = windowmap */
 
-      // Show window, then...
+      /* Show window, then... */
       gst_cea708dec_for_each_window (decoder, window_list, NO_CHANGE,
           "display_window", gst_cea708dec_show_window);
 
-      // Delete window
+      /* Delete window */
       gst_cea708dec_for_each_window (decoder, window_list, NO_CHANGE,
           "delete_window", gst_cea708dec_init_window);
       return;
 
-      //----- Delay ----------------------------------------------------------
-    case CC_COMMAND_DLY:
-      decoder->output_ignore = 1;       // 1 byte parameter = delay in 1/10 sec
-      // TODO: - process this command.
+    case CC_COMMAND_DLY:       /* Delay */
+      decoder->output_ignore = 1;       /* 1 byte parameter = delay in 1/10 sec */
+      /* TODO: - process this command. */
       return;
 
-      //----- Delay cancel ---------------------------------------------------
-    case CC_COMMAND_DLC:
-      // TODO: - process this command.
+    case CC_COMMAND_DLC:       /* Delay cancel */
+      /* TODO: - process this command. */
       return;
 
-      //----- Reset ----------------------------------------------------------
+      /* Reset */
     case CC_COMMAND_RST:
-      // Reset - cancel any delay, delete all windows
-      window_list = 0xFF;       // all windows...
+      /* Reset - cancel any delay, delete all windows */
+      window_list = 0xFF;       /* all windows... */
 
-      // Delete window
+      /* Delete window */
       gst_cea708dec_for_each_window (decoder, window_list, NO_CHANGE,
           "reset_window", gst_cea708dec_init_window);
       return;
 
-      //----- Set pen attributes -------------------------------------------
-    case CC_COMMAND_SPA:
-      decoder->output_ignore = 2;       // 2 byte parameter = pen attributes
+    case CC_COMMAND_SPA:       /* Set pen attributes */
+      decoder->output_ignore = 2;       /* 2 byte parameter = pen attributes */
       gst_cea708dec_set_pen_attributes (decoder, dtvcc_buffer, index + 1);
       return;
 
-      //----- Set pen color ------------------------------------------------
-    case CC_COMMAND_SPC:
-      decoder->output_ignore = 3;       // 3 byte parameter = color & opacity
+    case CC_COMMAND_SPC:       /* Set pen color */
+      decoder->output_ignore = 3;       /* 3 byte parameter = color & opacity */
       gst_cea708dec_set_pen_color (decoder, dtvcc_buffer, index + 1);
       return;
 
-      //----- Set pen location ---------------------------------------------
-    case CC_COMMAND_SPL:
-      // Set pen location - row, column address within the current window
-      decoder->output_ignore = 2;       // 2 byte parameter = row, col
+    case CC_COMMAND_SPL:       /* Set pen location */
+      /* Set pen location - row, column address within the current window */
+      decoder->output_ignore = 2;       /* 2 byte parameter = row, col */
       window->pen_row = dtvcc_buffer[index + 1] & 0xF;
       window->pen_col = dtvcc_buffer[index + 2] & 0x3F;
-      GST_DEBUG_OBJECT (decoder, "Pen location: row=%d col=%d",
+      GST_LOG_OBJECT (decoder, "Pen location: row=%d col=%d",
           window->pen_row, window->pen_col);
       return;
 
-      //----- Set window attributes ----------------------------------------
-    case CC_COMMAND_SWA:
-      // Set window attributes - color, word wrap, border, scroll effect, etc
-      decoder->output_ignore = 4;       // 4 byte parameter = window attributes
+    case CC_COMMAND_SWA:       /* Set window attributes */
+      /* Set window attributes - color, word wrap, border, scroll effect, etc */
+      decoder->output_ignore = 4;       /* 4 byte parameter = window attributes */
       gst_cea708dec_set_window_attributes (decoder, dtvcc_buffer, index + 1);
       return;
 
-      //----- Define window ------------------------------------------------
-    case CC_COMMAND_DF0:
+    case CC_COMMAND_DF0:       /* Define window */
     case CC_COMMAND_DF1:
     case CC_COMMAND_DF2:
     case CC_COMMAND_DF3:
@@ -1550,21 +1467,21 @@ gst_cea708dec_process_dtvcc_byte (GstCea708Dec * decoder, guint8 * dtvcc_buffer,
     case CC_COMMAND_DF6:
     case CC_COMMAND_DF7:
     {
-      window_list = 0xFF;       // all windows...
+      window_list = 0xFF;       /* all windows... */
 
-      // Show window, then...
+      /* Show window, then... */
       gst_cea708dec_for_each_window (decoder, window_list, NO_CHANGE,
           "display_window", gst_cea708dec_show_window);
 
-      // set window - size, style, pen style, anchor position, etc.
-      decoder->output_ignore = 6;       // 6 byte parameter = window definition
+      /* set window - size, style, pen style, anchor position, etc. */
+      decoder->output_ignore = 6;       /* 6 byte parameter = window definition */
       decoder->current_window = c & 0x3;
       gst_cea708dec_define_window (decoder, dtvcc_buffer, index + 1);
       return;
     }
   }
 
-  // A normal text character - add to the current string
+  /* A normal text character - add to the current string */
   gst_cea708dec_window_add_char (decoder, c);
 }
 
@@ -1574,7 +1491,7 @@ gst_cea708dec_process_dtvcc_packet (GstCea708Dec * decoder,
 {
   guint i;
 
-  // Service block header (see CEA-708 6.2.1)
+  /* Service block header (see CEA-708 6.2.1) */
   guint8 block_size;
   guint8 service_number;
 
@@ -1588,7 +1505,7 @@ gst_cea708dec_process_dtvcc_packet (GstCea708Dec * decoder,
   parse_index += 1;
 
   if (service_number == 7) {
-    // Get extended service number
+    /* Get extended service number */
     service_number = dtvcc_buffer[parse_index] & 0x3F;
     parse_index += 1;
   }
@@ -1596,8 +1513,8 @@ gst_cea708dec_process_dtvcc_packet (GstCea708Dec * decoder,
   GST_LOG_OBJECT (decoder, "size=%d seq=%d block_size=%d service_num=%d",
       pkt_size, sequence_number, block_size, service_number);
 
-  // If there has been a change in the desired service number, then clear
-  // the windows for the new service.
+  /* If there has been a change in the desired service number, then clear
+   * the windows for the new service. */
   if (decoder->desired_service != decoder->previous_desired_service) {
     for (i = 0; i < MAX_708_WINDOWS; i++) {
       gst_cea708dec_init_window (decoder, i);
@@ -1606,14 +1523,14 @@ gst_cea708dec_process_dtvcc_packet (GstCea708Dec * decoder,
     decoder->current_window = 0;
     decoder->previous_desired_service = decoder->desired_service;
   }
-  // If the desired_service has been set to a number other than -1, then
-  // filter the packets based on the that service number.
+  /* If the desired_service has been set to a number other than -1, then
+   * filter the packets based on the that service number. */
   if ((decoder->desired_service == -1)
       || (decoder->desired_service == service_number)) {
     for (i = 0; i < block_size; i++) {
-      // The Dtvcc buffer contains a stream of commands, command parameters,
-      // and characters which are the actual captions. Process commands and
-      // store captions in simulated 708 windows:
+      /* The Dtvcc buffer contains a stream of commands, command parameters,
+       * and characters which are the actual captions. Process commands and
+       * store captions in simulated 708 windows: */
       gst_cea708dec_process_dtvcc_byte (decoder, dtvcc_buffer, parse_index + i);
     }
   }
@@ -1642,15 +1559,16 @@ gst_cea708dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
   GstMapInfo map = { 0 };
   gint len = 0;
 
-  // if this is the first output, initialize our output pad...
+  /* if this is the first output, initialize our output pad... */
   if (NULL == decoder->srcpad) {
     gst_cea708dec_add_text_srcpad (decoder);
 
     len = gst_cea708dec_text_list_add (GST_OBJECT (decoder),
         &decoder->text_list, sizeof ("WEBVTT\n\n\n") + 1, "WEBVTT\n\n\n");
-    gst_cea708dec_send_text (GST_OBJECT (decoder), &decoder->text_list, len,
+    ret_val =
+        gst_cea708dec_send_text (GST_OBJECT (decoder), &decoder->text_list, len,
         decoder->srcpad);
-    GST_INFO_OBJECT (decoder, "src pad added to decoder");
+    GST_DEBUG_OBJECT (decoder, "src pad added to decoder");
   }
 
   decoder->current_time = GST_BUFFER_PTS (buf);
@@ -1665,23 +1583,3 @@ gst_cea708dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
   return ret_val;
 }
 
-#ifdef STANDALONE_ELEMENT
-static gboolean
-decoder_init (GstPlugin * plugin)
-{
-  gboolean res = FALSE;
-
-  gst_tag_register_musicbrainz_tags ();
-
-  GST_DEBUG_CATEGORY_INIT (gst_cea708dec_debug, "cea708dec", 0, "CC Decoder");
-  res = gst_element_register (plugin, "cea708dec",
-      GST_RANK_PRIMARY, GST_TYPE_CEA708DEC);
-  return res;
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
-    GST_VERSION_MINOR,
-    ccdecbad,
-    "cea708dec",
-    decoder_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
-#endif
diff --git a/gst/ccdec/gstcea708dec.h b/gst/ccdec/gstcea708dec.h
index e97ad73..f80e052 100644
--- a/gst/ccdec/gstcea708dec.h
+++ b/gst/ccdec/gstcea708dec.h
@@ -393,6 +393,50 @@ typedef struct
   cea708char text[WINDOW_MAX_ROWS][WINDOW_MAX_COLS];
 } cea708Window;
 
+/* This element's private data */
+struct _GstCea708Dec
+{
+  /* Storage for parent Element */
+  GstElement element;
+
+  /* Element pads */
+  GstPad *sinkpad;
+  GstPad *srcpad;
+
+  /* output data storage */
+  GSList *text_list;
+
+  /* simulation of 708 CC windows */
+  cea708Window *cc_windows[MAX_708_WINDOWS];
+  guint8 current_window;
+
+  /* a counter used to ignore bytes in CC text stream following commands */
+  gint8 output_ignore;
+
+  guint64 current_time;         /* most recent timestamp from userdata */
+
+  /* desired_service selects the service that will be decoded. If
+   * desired_service = -1 (default) no decoding based on service number will
+   * occur. Service #0 is reserved, and the valid range of service numbers
+   * is 1-6 with 1 being primary caption service and 2 being the secondary
+   * language service. */
+  gint8 desired_service;
+
+  /* previous_desired_service is used to detect a change in the desired
+   * service. When changing service number, only change the desired_service
+   * variable */
+  gint8 previous_desired_service;
+
+  /* holds the most recent segment data for a new segment event */
+  GstSegment segment;
+};
+
+struct _GstCea708DecClass
+{
+  /* Storage for parent ElementClass */
+  GstElementClass parent_class;
+};
+
 
 typedef struct _GstCea708Dec GstCea708Dec;
 typedef struct _GstCea708DecClass GstCea708DecClass;
diff --git a/gst/ccdec/plugin.c b/gst/ccdec/plugin.c
index 49cc8bf..10a3653 100644
--- a/gst/ccdec/plugin.c
+++ b/gst/ccdec/plugin.c
@@ -43,6 +43,6 @@ plugin_init (GstPlugin * plugin)
 
 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
     GST_VERSION_MINOR,
-    ccdecbad,
+    ccdec,
     "ccdecoders",
     plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
