Broke up over-long function.