Added Comments and changed some variable names around to improve readability.