Updated to work in ruby 1.8.7, 1.9.3 and 2.0.0