Fix refactoring bugs.