Changes suggested by @phihag