Bug fixes on resize