Rename variables to meet C# naming conventions
Also some minor refactoring