* some js refactorings and hooks