Forked from GitHub. Proted to .NET 4.5. Massive clean'up and rewrite using generics