Fixed an issue when we attempted to run a defer with NoneType