brought fixes from Greg's Leanne project into mine