Misc fixes noticed while translating to C#