Major refactoring on typeahead_tag.js