Restructure js files to more logic and less everything every where.