Fix bugs after recent refactoring.