Doing a lot of converting to c#