Fix buggy scrollspy when dom changes