init, loop and buffer clean