Improved the resynthesis algorithm