minor improvements over Remi's work