Script is slightly more modularized

Will continue to modularize to make it work in a variety of situations