Fixed threading issues and added progress bar