refactor bootloader 2
move to shared files
finish refactoring