Fix to handle window maximizing not working correctly