Add some parfor to speed up.
Add some code to record the stage time.