Working version with some enhancements to the way the starting sizes were determined to stop flickering of elements dimensions when only changing one property.