Corrected some bugs and modified comments