converted a bunch of scripts to C#