Add progress counter and fix stalling UI thread