Fixed some bugs from merge