Fix bugs introduced by recent refactoring.