swap dialog fix, lots of bug fixes