Big cleanup in order to make everything more C# friendly