 
 						adjustAfterFetch(rid) if adjustAfterFetch
 
-						#topVisible is not necessarily the first item in the buffer
 						if pending.length == 0
 							topHeight = 0
 							for item in buffer

										++next
										insertItem 'append', item
										#log 'appended: requested ' + bufferSize + ' received ' + result.length + ' buffer size ' + buffer.length + ' first ' + first + ' next ' + next
								finalize rid
					else
						if buffer.length && !shouldLoadTop()
							finalize rid
						else
							#log "prepending... requested #{size} records starting from #{start}"
							datasource.get first-bufferSize, bufferSize,

								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 ->

						[keepFetching, promises] = processBufferedItems()

						if shouldLoadBottom()
							# keepFetching = true means that at least one item app/prepended in the last batch had height > 0
