Make some fixes related to Ticket #3662. Its mostly cleanup.