fixed gdist_prep, added error messages