Ported from the Java implementation.
Which in turn is ported from the C# implementation.
There are a number of improvements planned:
- refactor various classes to improve the API
- improve comments
- add example usage
- improve unit tests