Fix more refactor bugs