additional checks, restoringEnergy, minor refactoring