Switched to Ruby implementation

According to benchmarks, it should be faster up to 2x.