Fixed some bugs

Fixed some bugs after merging