Clean buffer/window code