nasty bug fixed, and hooks added