Added scanbuffe and nextitem functions.