Added documentation and changed some variable names.