Code Restructured and Commented

I have restructured the code to how I prefer it to look and commented
it.