Implemented suggestions by JohnLambe.