Fix some variable definitions their scope