public BufferView getPage(int pageIndex) {
        if(pageIdxToBufferPos.containsKey(pageIndex)) {
            int bufferPos = pageIdxToBufferPos.get(pageIndex);
            return new BufferView(buffer, bufferPos, (int) PAGE_SIZE, this);
        }
        
        // Clock algorithm
        while(true) {
	        currentPos = bufferIsUsed.nextClearBit(currentPos + 1);
	        if(currentPos == BUFFER_SIZE) {
	        	currentPos = bufferIsUsed.nextClearBit(0);
	        }
	        if(currentPos == BUFFER_SIZE) {
	            throw new RuntimeException("All buffer positions are in use! Panic!");
	        }
	        if(bufferWasUsed.get(currentPos)) {
	        	bufferWasUsed.clear(currentPos);
	        } else {
	        	break;
	        }
        }
        if(bufferChanged.get(currentPos)) {
            writePage(currentPos);
        }
        pageIdxToBufferPos.remove(bufferPosToPageIdx[currentPos]);
        bufferPosToPageIdx[currentPos] = -1;
        loadPage(pageIndex, currentPos);
        return new BufferView(buffer, currentPos, (int) PAGE_SIZE, this);
    }