Automate program transformation and handle errors better