Added debugging and timing messages. Refactored setting of @lang attribute.