Completed initial conversion to CSharp