Fixed some issues with target gen between stages

Still have to fix the issue which occurs between the second and third
stages