Refactor apply_tag_handlers_collection to smaller functions