Refactors the Ui JS file. To Be Continued [Stable]