refactored and implemented hooks, simple logging, and performance counters.
Minor code review changes.