Pull request for all the remaining patches, including the new performance monitors.

Function can be qualified with const.