Fixed the bug in decoupling script that made it do to many repetitions. Also added some comments