Fix global variable usage and cleanup whitespace

A simple patch that prevents variable leakage into the global namespace.