TS-2555: updates to share lua context across hook invocations and only add global hooks if corresponding lua functions exist
TS-2555: fix build failure related to unused variable