hook api

Hook API and necessary test changes. See inline comments for details / discussion.