Commented most of the code so i can understand it more easily and tidied
up some parts