refactoring and bootstrap cleanup