EZP-21913: Fixed usage of global in indexing script

See http://jira.ez.no/browse/EZP-21913

Gets rid of the requirement of globals completely.