Some refactoring
Remove the ugly public hook API

Need something better than this. It's just ugly and error-prone.