Refactored tons of variables and cleaned the code for restructure