Fixing several bugs related to recent changes.