Fix several bugs in new instrumentation.
Fix tests for instrumentation.