Fix some minor bugs detected by source analysis
Update XWT