Ruby 2.0 compatibility

Ruby 2.0 introduced some breaking changes. See details in commit messages.