Hopefully made code a little more readable. Added attribution of code structure.