Some hooks and debugging