Move some useful functions out of analyzeStops into a module.