redesign main engine for new stack design