Move bufferedVideo flushing to separate function, add logging