merging in change from bilderbuchi as best I could