add hooks and fix issues in scripts