Fix fatal errors in hook.php