Console.InputEncoding/OutputEncoding and System.Threading.Thread.GetNewManagedID fixes.