 								wrapper.unregister()
 						false
 
+				processBufferedItems = ->
+					promises = []
+					toBePrepended = []
+					toBeRemoved = []
+
+					bottomPos = builder.bottomDataPos()
+					for wrapper, i in buffer
+						switch wrapper.op
+							when 'prepend' then toBePrepended.unshift wrapper
+							when 'append'
+								if (i == 0) # the first item in buffer is to be appended, therefore the buffer was empty
+									keepFetching = insertWrapperContent(wrapper) || keepFetching
+								else
+									keepFetching = insertWrapperContent(wrapper, buffer[i-1].element) || keepFetching
+								wrapper.op = 'none'
+							when 'insert'
+								if (i == 0)
+									promises = promises.concat (builder.insertElementAnimated wrapper.element)
+								else
+									promises = promises.concat (builder.insertElementAnimated wrapper.element, buffer[i-1].element)
+								wrapper.op = 'none'
+							when 'remove' then toBeRemoved.push wrapper
+
+					for wrapper in toBeRemoved
+						promises = promises.concat (removeItem wrapper)
+
+					# for anything other than prepend adjust the bottomPadding height
+					builder.bottomPadding(Math.max(0,builder.bottomPadding() - (builder.bottomDataPos() - bottomPos)))
+
+					if toBePrepended.length
+						bottomPos = builder.bottomDataPos()
+						for wrapper in toBePrepended
+							keepFetching = insertWrapperContent(wrapper) || keepFetching
+							wrapper.op = 'none'
+
+						heightIncrement = builder.bottomDataPos() - bottomPos
+
+						# adjust padding to prevent it from visually pushing everything down
+						if builder.topPadding() >= heightIncrement
+							# if possible, reduce topPadding
+							builder.topPadding(builder.topPadding() - heightIncrement)
+						else
+							# if not, increment scrollTop
+							viewport.scrollTop(viewport.scrollTop() + heightIncrement)
+
+					# re-index the buffer
+					item.scope.$index = first + i for item,i in buffer
+					[keepFetching, promises]
+
 				adjustBuffer = (rid, adjustAfterFetch) ->
 
 					# We need the item bindings to be processed before we can do adjustment
 					$timeout ->
 
-						promises = []
-						toBePrepended = []
-						toBeRemoved = []
-
-						bottomPos = builder.bottomDataPos()
-						for wrapper, i in buffer
-							switch wrapper.op
-								when 'prepend' then toBePrepended.unshift wrapper
-								when 'append'
-									if (i == 0) # the first item in buffer is to be appended, therefore the buffer was empty
-										keepFetching = insertWrapperContent(wrapper) || keepFetching
-									else
-										keepFetching = insertWrapperContent(wrapper, buffer[i-1].element) || keepFetching
-									wrapper.op = 'none'
-								when 'insert'
-									if (i == 0)
-										promises = promises.concat (builder.insertElementAnimated wrapper.element)
-									else
-										promises = promises.concat (builder.insertElementAnimated wrapper.element, buffer[i-1].element)
-									wrapper.op = 'none'
-								when 'remove' then toBeRemoved.push wrapper
-
-						for wrapper in toBeRemoved
-							promises = promises.concat (removeItem wrapper)
-
-						# for anything other than prepend adjust the bottomPadding height
-						builder.bottomPadding(Math.max(0,builder.bottomPadding() - (builder.bottomDataPos() - bottomPos)))
-
-						if toBePrepended.length
-							bottomPos = builder.bottomDataPos()
-							for wrapper in toBePrepended
-								keepFetching = insertWrapperContent(wrapper) || keepFetching
-								wrapper.op = 'none'
-
-							heightIncrement = builder.bottomDataPos() - bottomPos
-
-							# adjust padding to prevent it from visually pushing everything down
-							if builder.topPadding() >= heightIncrement
-								# if possible, reduce topPadding
-								builder.topPadding(builder.topPadding() - heightIncrement)
-							else
-								# if not, increment scrollTop
-								viewport.scrollTop(viewport.scrollTop() + heightIncrement)
-
-						# re-index the buffer
-						item.scope.$index = first + i for item,i in buffer
-
-						#log "top {actual=#{builder.topDataPos()} visible from=#{topVisiblePos()} bottom {visible through=#{bottomVisiblePos()} actual=#{builder.bottomDataPos()}}"
+						[keepFetching, promises] = processBufferedItems()
 
 						if shouldLoadBottom()
 							# keepFetching = true means that at least one item app/prepended in the last batch had height > 0

										--first
										insertItem 'prepend', result[i]
									#log 'prepended: requested ' + bufferSize + ' received ' + result.length + ' buffer size ' + buffer.length + ' first ' + first + ' next ' + next
								finalize rid


				# events and bindings


						adjustAfterFetch(rid) if adjustAfterFetch

						if pending.length == 0
							topHeight = 0
							for item in buffer
