fix window resizing bug on some platforms and add -O1 optimization flag