engine class refactored