refactor changesgenerate code

Eliminate code duplication and long functions.
drop deprecated --use-mirrors option