Added comments and tidied some code, probably still messy, sorry
Merge that bad boy