Cleaning up the global namespace, renamed some vars for clarity.