Sort JS files based on minispade require dependencies
Fix code errors