Changed the window buffer flushing and some other issues