Refactored and fixed up script!
Big script update