refactoring of EspaldaEngine