pie.rb : some refactoring