Improved Java implementation
Merge pull request #1 from Alotor/master

Improved Java implementation