Copied first inital C# port, need tuning