improved thumbnail handling