Added TheEnd() as a defer for main and changed Defer func to LastDefer