Deleted  useless code and fixed small bugs.