Refactored and cleaned up. Trying to see if make stack space smaller.