Some fixes for Expect 1.21

Fixes the following issues:
rt-86852
rt-61395
rt-47268
rt-41482
rt-36970

These are really old bugs that were very simple (for me to fix).