Incorporated some suggestions from Greg