Bug fixes to restore old behavior after extensive refactoring.