Clean up the code, seperate config options from code in the script. Comment and explain the code better.