PL: Fixed assumed variables, removed naked globals (REF-290)