Code refactoring and bootstrap