add folds, some comments and fixed leg variables