Reworking how Agent is started and stopped in a thread if required