Clean up the code and implemented the progressBar.