Various fixes for Ruby implementation

Not much to say about this one.