Add hooks for open/close operations.