Fix hook code, add import, etc.