Added progressbar and thread functionality