Engine: Initial refactoring