Changed global variables to constants, but not $msgs.