fix Swap calling with pointer not by referencem, and fix some borland compiler wanrnings