fix bugs with thumbnail generation