implemented CreateThumbnailFromSurface and added some cleaning stuff.