refactoring and bugfix

Breaking up larger functions/methods into smaller ones, and a bugfix for changes generation when version is blank.