Refactor; use .NET classes where possible