Moved variable initialization to the beginning of the script.