Fixed bugs from merge