reorganized pre init and more refactoring