Refactor/breakup of monolithic JS