Fix old ruby

Made multiple changes that are required for compatibility with ruby 1.9.3. 
#79 should be fixed by this