Fixing thumbnail generation code