diff --git a/loopy/codegen/__init__.py b/loopy/codegen/__init__.py
index 4d7047df47aac397baa2e65b85999519477177c1..cf5a0ed69adb89925d206bbc246ac1b4384f48d0 100644
--- a/loopy/codegen/__init__.py
+++ b/loopy/codegen/__init__.py
@@ -128,9 +128,10 @@ class CodeGenerationState(object):
                 new_impl & new_other,
                 self.c_code_mapper)
 
-    def fix(self, iname, aff, space):
+    def fix(self, iname, aff):
         from loopy.isl_helpers import iname_rel_aff
-        iname_plus_lb_aff = iname_rel_aff(space, iname, "==", aff)
+        iname_plus_lb_aff = iname_rel_aff(
+                self.implemented_domain.get_space(), iname, "==", aff)
 
         from loopy.symbolic import pw_aff_to_expr
         cns = isl.Constraint.equality_from_aff(iname_plus_lb_aff)
diff --git a/loopy/codegen/loop.py b/loopy/codegen/loop.py
index 7b4e63c959f070ad047b8d89410696e5f11356bb..70ac54787ebcbefba014813aad468b67ac08b3b9 100644
--- a/loopy/codegen/loop.py
+++ b/loopy/codegen/loop.py
@@ -89,11 +89,11 @@ def get_slab_decomposition(kernel, iname, sched_index, codegen_state):
                     .add_constraint(ub_cns_orig)
                     .add_constraint(
                         isl.Constraint.inequality_from_aff(
-                            iname_rel_aff(kernel.space,
+                            iname_rel_aff(space,
                                 iname, ">=", upper_bound_aff-upper_incr))))
             upper_bulk_bound = (
                     isl.Constraint.inequality_from_aff(
-                        iname_rel_aff(kernel.space,
+                        iname_rel_aff(space,
                             iname, "<", upper_bound_aff-upper_incr)))
         else:
             lower_slab = None
@@ -144,7 +144,7 @@ def generate_unroll_loop(kernel, sched_index, codegen_state):
 
         for i in range(length):
             idx_aff = lower_bound_aff + i
-            new_codegen_state = codegen_state.fix(iname, idx_aff, kernel.space)
+            new_codegen_state = codegen_state.fix(iname, idx_aff)
             result.append(
                     build_loop_nest(kernel, sched_index+1, new_codegen_state))