clean up and add hooks