Add max(), min(), sum() methods. Refactor codes.