Restructure javascript files