fix bugs and improve reliability for trace runs