Adds progress function and fixes minor bugs.