Fixed crash when resizing to 0
Improved example code