I'll add code comments explaining everything so that stuff is clear.