CSharp: Cleaning up the code