Copied over global variables

Copied over global variables and made first amends to work in c#