refactored and remove migrate.js

Did some code cleanup and refactoring, removed code in migrate.js file
and reduced repeat logger code