Fix ClassCastException while calling hooks