More refactoring of piece.rb.