Initial port from C# sources.
Merge pull request #1 from johnvcoleman/develop

Initial port from C# sources.