I have taken all your advice and tried to work it out and am nearly there. The only problem is when a note should be repeated, instead of being repeated it just comes up with silence, i.e. converts the repeated number into a note off. Instead of a note off, I want another note to be played which is not a repeated note.
Attached is the current setup that i have in the maxpat. If you guys could continue to help me out I would be really greatful.
Also if you have any tips or techniques on how to clean up the whole interconnected numbers bit in the middle, that would also be greatly appreciated.