refactor: clean code and update to ruby 1.9 code