Refactored the reply processing functions.