Simplified by adding a dictionary

I replaced 'data[][]' with a dictionary which made it easier to read the code.
I also removed several functions that didn't really need to exist, as the code only appeared once.
I also removed some of the commenting as I felt it didn't add any value.