Added global variables and fixed thousands of bugs!