Small refactoring to break up the large handler functions.