Fixes for issue #2227 and #2228

Some minor changes that address issues #2227 and #2228 (plus issue #2225 but a better fix for that is in #2226).