Refactors JS organization