Minor fixes

Corrected the bug in the previous pull-request.

See individual commits for more details.