Draft (only *very* briefly tested, and not really finished) attempt at instrumentation hooks.