diff --git a/f265/inter.c b/f265/inter.c
index 95f3a43..89e3ed3 100644
--- a/f265/inter.c
+++ b/f265/inter.c
@@ -437,10 +437,12 @@ void fenc_frame_set_up_inter_pred(f265_enc_thread *t)
 // Load the temporal PMVs. Should be called at every CTB.
 void fenc_ctb_set_up_inter_pred(f265_enc_thread *t)
 {
+    f265_gen_data *gd = &t->enc->gd;
+
     // Skip this function if we don't use TMV or this is intra.
-    if (!(t->enc->gd.eflags & F265_PF_TMV) || !t->nb_lists) return;
+    if (!(gd->eflags & F265_PF_TMV) || !t->nb_lists) return;
 
-    int b4_stride = t->enc->gd.pix_dim[0] >> 2;
+    int b4_stride = gd->pix_dim[0] >> 2;
     int b4_x = (t->ctb_off[0] >> 2);
     int b4_y = (t->ctb_off[1] >> 2);
     int b4_off = b4_y * b4_stride + b4_x;
@@ -452,10 +454,10 @@ void fenc_ctb_set_up_inter_pred(f265_enc_thread *t)
     {
         // Since we may use a TMV from a neighbour on the right of the current
         // CTB, allocate an additional block horizontally.
-        max[i] = ((1 << t->cb[0].lg_bs) >> 4) + !i;
+        max[i] = (gd->ctb_size >> 4) + !i;
 
         // Clip to the frame border.
-        int delta_past_border = (t->ctb_off[i] + (1 << t->cb[0].lg_bs)) - t->enc->gd.pix_dim[i];
+        int delta_past_border = (t->ctb_off[i] + gd->ctb_size) - gd->pix_dim[i];
         if (unlikely(delta_past_border >= 0))
             max[i] -= (delta_past_border >> 4) + !i;
     }
@@ -479,8 +481,8 @@ void fenc_ctb_set_up_inter_pred(f265_enc_thread *t)
         }
 
         // The scaling factors cancel out here.
-        mv += t->enc->gd.pix_dim[0];
-        ref += t->enc->gd.pix_dim[0];
+        mv += gd->pix_dim[0];
+        ref += gd->pix_dim[0];
     }
 }
 
