Fix the hooks/callbacks feature

This fixes #531.