Add a progress bar and fix bugs