Fixed scope issues