Fix scope issues