diff --git a/silk/structs.h b/silk/structs.h
index 32574164635c81180b8e514091b889855965614a..48f47f55d66cfa533224f465e054a60635802efa 100644
--- a/silk/structs.h
+++ b/silk/structs.h
@@ -265,6 +265,7 @@ typedef struct {
     DREDDec                     dred_decoder;
     float                       fec_features[2*DRED_NUM_REDUNDANCY_FRAMES*DRED_NUM_FEATURES];
     int                         nb_fec_frames;
+    int                         pre_filled;
 #endif
 #endif
 } silk_PLC_struct;
diff --git a/src/opus_decoder.c b/src/opus_decoder.c
index d4595a67784647ead6c877a2cd5e4a242c6563d8..7f61292a8f991daba4fd6c8540c11dc3ef51d45a 100644
--- a/src/opus_decoder.c
+++ b/src/opus_decoder.c
@@ -398,7 +398,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,
         }
      }
 
-     lost_flag = data == NULL ? 1 : 2 * decode_fec;
+     lost_flag = data == NULL ? 1 : 2 * !!decode_fec;
      decoded_samples = 0;
      do {
         /* Call SILK decoder */
@@ -643,14 +643,32 @@ int opus_decode_native(OpusDecoder *st, const unsigned char *data,
    int count, offset;
    unsigned char toc;
    int packet_frame_size, packet_bandwidth, packet_mode, packet_stream_channels;
+   silk_decoder_state *silk_dec;
    /* 48 x 2.5 ms = 120 ms */
    opus_int16 size[48];
    VALIDATE_OPUS_DECODER(st);
-   if (decode_fec<0 || decode_fec>1)
+   silk_dec = (silk_decoder_state*)((char*)st+st->silk_dec_offset);
+   if (decode_fec<0 || (decode_fec>1 && data!=NULL))
       return OPUS_BAD_ARG;
    /* For FEC/PLC, frame_size has to be to have a multiple of 2.5 ms */
    if ((decode_fec || len==0 || data==NULL) && frame_size%(st->Fs/400)!=0)
       return OPUS_BAD_ARG;
+   if (decode_fec > 0) {
+      int features_per_frame;
+      int needed_feature_frames;
+      features_per_frame = frame_size/(st->Fs/100);
+      needed_feature_frames = features_per_frame;
+      if (!silk_dec->sPLC.pre_filled) needed_feature_frames+=2;
+      silk_dec->sPLC.pre_filled = 1;
+      for (i=0;i<needed_feature_frames;i++) {
+         int feature_offset = (needed_feature_frames-i-1 + (decode_fec-1)*features_per_frame);
+         /* FIXME: Find something better than that (involving actual PLC) */
+         feature_offset = IMIN(feature_offset, silk_dec->sPLC.nb_fec_frames-1);
+         lpcnet_plc_fec_add(silk_dec->sPLC.lpcnet, silk_dec->sPLC.fec_features+feature_offset*DRED_NUM_FEATURES);
+      }
+   } else {
+     silk_dec->sPLC.pre_filled = 0;
+   }
    if (len==0 || data==NULL)
    {
       int pcm_count=0;
diff --git a/src/opus_demo.c b/src/opus_demo.c
index 3301df2ecf6bedbb00ab0010015b6ade603c5295..c154b98e79645a42142550a38d31b44171860342 100644
--- a/src/opus_demo.c
+++ b/src/opus_demo.c
@@ -770,12 +770,15 @@ int main(int argc, char *argv[])
             }
             if (run_decoder)
                 run_decoder += lost_count;
+            if (!lost && lost_count > 0) {
+                opus_decoder_dred_input(dec, data, len, 100);
+            }
             /* FIXME: Figure out how to trigger the decoder when the last packet of the file is lost. */
             for (fr=0;fr<run_decoder;fr++) {
                 opus_int32 output_samples=0;
                 if (fr < lost_count-1) {
                    opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&output_samples));
-                   output_samples = opus_decode(dec, NULL, 0, out, output_samples, 1);
+                   output_samples = opus_decode(dec, NULL, 0, out, output_samples, lost_count-fr);
                 } else if (fr == lost_count-1) {
                    opus_decoder_ctl(dec, OPUS_GET_LAST_PACKET_DURATION(&output_samples));
                    output_samples = opus_decode(dec, data, len, out, output_samples, 1);