Refactored to separate globals and constants.