Fixed error mesges and some bugs