Added comments and explanations on what everything does.