Change order of definition, add missing variable definitions.