Added some changes suggested by Ian