Merge james's patch (bug #7)