restructure and fix bootloader