port to Ruby1.9+ a little bit further