Refactor boot code a bit.