self._finish_refresh()
             while self._refreshing:
                 # TODO: Add something here that can change self._refreshing
+                # or add something in _background()
                 pass
 
         self._start_refresh()
         # If there is no overlap then we're done.
         if not self._core.clip_area(area, clipped):
             return True
-        print("---------------")
-        print(area.x1, area.y1, area.x2, area.y2)
-        print(clipped.x1, clipped.y1, clipped.x2, clipped.y2)
-        print("---------------")
         subrectangles = 1
         rows_per_buffer = clipped.height()
         pixels_per_word = 32 // self._core.colorspace.depth
                 if (pass_index == 1 and self._color_bits_inverted) or (
                     pass_index == 0 and self._black_bits_inverted
                 ):
-                    for i, _ in enumerate(buffer):
+                    for i in range(buffer_size):
                         buffer[i] = ~buffer[i]
 
                 if not self._core.begin_transaction():