Added support for handling text items in the same manner as the main script.