Refactored a bit and added a signal when concept to be able to wait for external conditions.