Found and fixed bug in merge

Merge tested and working in full