Add comments and rename some variables with more sensible names