fix a few bugs related to 'timing' demo