Fixed some bugs caused by the merge with master