Fixed small bugs with main variable