Remove duplicate main function.
Make reverse and term_reverse into function.