change some variable names and add free_model, free_param & check_param