Instrument most functions.
Merge pull request #1641 from mbebenita/instrument

Instrument most functions.