Delete all thumbnails on image deleting. Some fixes and improvements of code and design.