Tidying up of source to make it more presentable for my understanding