Plain Java implementation added, refactored, not tested yet