Fixed some bugs
Manual merge