Fix scope problems