anchor.diff:  	if(src.secondsMainPowerLost > 0)
   		src.secondsMainPowerLost = 0
   
  +/obj/machinery/door/airlock/proc/handlePowerRestore()
  +	var/cont = TRUE
  +	while (cont)
  +		sleep(10)
  +		if(QDELETED(src))
  +			return
  +		cont = FALSE
  +		if(secondsMainPowerLost>0)
  +			if(!wires.is_cut(WIRE_POWER1) && !wires.is_cut(WIRE_POWER2))
  +				secondsMainPowerLost -= 1
  +				updateDialog()
  +			cont = TRUE
  +		if(secondsBackupPowerLost>0)
  +			if(!wires.is_cut(WIRE_BACKUP1) && !wires.is_cut(WIRE_BACKUP2))
  +				secondsBackupPowerLost -= 1
  +				updateDialog()
  +			cont = TRUE
  +	spawnPowerRestoreRunning = FALSE
  +	updateDialog()
  +
   /obj/machinery/door/airlock/proc/loseMainPower()
  -	if(src.secondsMainPowerLost <= 0)
  -		src.secondsMainPowerLost = 60
  -		if(src.secondsBackupPowerLost < 10)
  -			src.secondsBackupPowerLost = 10
  -	if(!src.spawnPowerRestoreRunning)
  +	if(secondsMainPowerLost <= 0)
  +		secondsMainPowerLost = 60
  +		if(secondsBackupPowerLost < 10)
  +			secondsBackupPowerLost = 10
  +	if(!spawnPowerRestoreRunning)
   		spawnPowerRestoreRunning = TRUE
  -		spawn(0)
  -			var/cont = 1
  -			while (cont)
  -				sleep(10)
  -				if(QDELETED(src))
  -					return
  -				cont = 0
  -				if(secondsMainPowerLost>0)
  -					if(!wires.is_cut(WIRE_POWER1) && !wires.is_cut(WIRE_POWER2))
  -						secondsMainPowerLost -= 1
  -						updateDialog()
  -					cont = 1
  -
  -				if(secondsBackupPowerLost>0)
  -					if(!wires.is_cut(WIRE_BACKUP1) && !wires.is_cut(WIRE_BACKUP2))
  -						secondsBackupPowerLost -= 1
  -						updateDialog()
  -					cont = 1
  -			spawnPowerRestoreRunning = FALSE
  -			updateDialog()
  +	INVOKE_ASYNC(src, .proc/handlePowerRestore)
   
   /obj/machinery/door/airlock/proc/loseBackupPower()
   	if(src.secondsBackupPowerLost < 60)
  
positive.code: 						shockedby += "\[[time_stamp()]\][usr](ckey:[usr.ckey])"
  						add_logs(usr, src, "electrified")
  						set_electrified(30)
  						spawn(10)
  							while (secondsElectrified > 0)
  								secondsElectrified--
  								if(secondsElectrified <= 0)
  									set_electrified(NOT_ELECTRIFIED)
  								updateUsrDialog()
  								sleep(10)
  				if(6)
  					//electrify door indefinitely
  					if(wires.is_cut(WIRE_SHOCK))
  
negative.code: 		..()
  	return
  
  /obj/machinery/door/airlock/proc/electrified_loop()
  	while (secondsElectrified > 0)
  		secondsElectrified--
  		if(secondsElectrified <= 0)
  			set_electrified(NOT_ELECTRIFIED)
  			updateUsrDialog()
  			sleep(10)
  
  /obj/machinery/door/airlock/Topic(href, href_list, var/nowindow = 0)
  	// If you add an if(..()) check you must first remove the var/nowindow parameter.
  