some corrections and bugfixes for swapping