Refactor bootstrap and loader