More tweaks and minor restructuring of bootloader