Changed quite a few variable names

The semantics of the code should be a little more obvious