Fix ruby 1.9.3 warnings

Fix warnings made by Ruby 1.9.2 or 1.9.3.

This is similar to #64, but only some of the changes are included, and the commits have got more verbose comments.