Fix old ruby

Made multiple changes that are required for compatibility with ruby 1.9.3