some fixes to handle resizing better