Some JS refactor
Added dependent destroy