A rewrite of an old program from C# to Python