Fixed some bugs

#573