Add missing terms variable.

Change-Id: Id57eee9983c8fd7cd789e445c77abb3f1b0304ec
Fix errors if fields are not set.

Change-Id: Ida28796188b6d71708e8b5280958db43f510197e