Generate folder image, improve code