Added clearing of some variables and corrected some prints