Fixed an issue with the SwapWindows function