Added missing hooks and fixed various bugs