Fixed some bugs , cleaning junk code