Code cleanup
Fixed error handling while generating thumbnails