Incorporated enhancements by Mike Slinn