Backporting the work from 2013 to make widgets resizable.
Some improvments for resizing