Converted variable names to the expected form.

Hard coded constants as global variables instead of leaving them as numbers in every function