Fixed bugs introduced from merge