Fix errors with ruby 1.8

Make the code work also with ruby 1.8