Large refactoring, swap_chars.pas now works