Bug fixes - Out for vengence.

See commit messages.

Fixes #5447
Fixes #5574
Fixes #5444
Fixes #5287
Fixes #5518
Fixes #5728
Fixes #5500