refactor of engine core