added some safeguard code around detecting swap already being activated, corrected some logic around stop procedure