refactoring and various loading order changes