fixed random hangs at drawing the main window