fix resize related bugs.