Refractor and swapEntry bugfix