Pure ruby implementation.