These handlers are long enough that I think they should get split out into separate functions.